/** * Stops all threads in this thread pool gracefully. This method will not * return until all threads have been terminated and joined successfully. */ public void stop() { List tms; synchronized (this) { stop = true; tms = (List) taskManagers.clone(); } for (int i=0; i<tms.size(); i++) { TaskManager tm = (TaskManager) tms.get(i); tm.terminate(); synchronized (tm) { tm.notify(); } try { tm.join(); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } } }
/** * Cancels all threads non-blocking by interrupting them. */ public synchronized void cancel() { stop = true; for (int i=0; i<taskManagers.size(); i++) { TaskManager tm = (TaskManager) taskManagers.get(i); tm.terminate(); tm.interrupt(); } }
/** * Stops all threads in this thread pool gracefully. This method will not * return until all threads have been terminated and joined successfully. */ @SuppressWarnings("unchecked") public void stop() { List<? extends TaskManager> tms; synchronized (this) { stop = true; tms = (List<? extends TaskManager>) taskManagers.clone(); } for (TaskManager tm : tms) { tm.terminate(); synchronized (tm) { tm.notify(); } try { tm.join(); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } } }
/** * Stops all threads in this thread pool gracefully. This method will not * return until all threads have been terminated and joined successfully. */ @SuppressWarnings("unchecked") public void stop() { List<? extends TaskManager> tms; synchronized (this) { stop = true; tms = taskManagers; } for (TaskManager tm : tms) { tm.terminate(); synchronized (tm) { tm.notify(); } try { tm.join(); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } } }
/** * Cancels all threads non-blocking by interrupting them. */ public void cancel() { stop = true; for (TaskManager tm : taskManagers) { tm.terminate(); tm.interrupt(); } }
/** * Cancels all threads non-blocking by interrupting them. */ public void cancel() { stop = true; for (TaskManager tm : taskManagers) { tm.terminate(); tm.interrupt(); } }