/** Terminates the threads. */ public void terminate() { while (hasJobs()) { try { Thread.sleep(100); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } for (int i = 0; i < workers.length; i++) { try { while (workers[i].isAlive()) { workers[i].interrupt(); workers[i].join(100); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } ec.close(); }