/** * Stops the timer, cancelling all tasks * * @throws InterruptedException if interrupted while waiting for thread to return */ public void stop() { stopRunner(); java.util.List<Runnable> remaining_tasks = pool.shutdownNow(); for (Runnable task : remaining_tasks) { if (task instanceof Future) { Future future = (Future) task; future.cancel(true); } } pool.getQueue().clear(); try { pool.awaitTermination(Global.THREADPOOL_SHUTDOWN_WAIT_TIME, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { } for (Entry entry : tasks.values()) entry.cancel(); tasks.clear(); }
public int getQueueSize() { return pool.getQueue().size(); }