/** * Shutdowns the working queue and wait until all pending requests have * been processed. This needs to be reviewed as jobs can still be added * to the queue once the shutdown process has started.... * @throws InterruptedException if the shutdown sequence is interrupted */ public synchronized void shutdown() throws InterruptedException { // push as many death pills as necessary for (Thread t : mWorkThreads) { _push(new QueueTask<T>(QueueTask.ActionType.Death, null)); } // we could use a latch. for (Thread t : mWorkThreads) { t.join(); } mWorkThreads.clear(); mQueueThreadContext.shutdown(); }
try { verbose("Creating a new working thread %1$s", threadName); mQueueThreadContext.creation(Thread.currentThread()); } catch (IOException e) { e.printStackTrace(); mQueueThreadContext.runTask(job); } catch (Exception e) { Logger.getAnonymousLogger().log(Level.WARNING, "Exception while processing task ", e); try { verbose("Thread(%1$s): destruction", threadName); mQueueThreadContext.destruction(Thread.currentThread()); } catch (IOException e) { mLogger.error(e, "Thread(%1$s): %2$s", threadName, e.getMessage());
try { verbose("Creating a new working thread %1$s", threadName); mQueueThreadContext.creation(Thread.currentThread()); } catch (IOException e) { e.printStackTrace(); mQueueThreadContext.runTask(job); } catch (Exception e) { mLogger.warning("Exception while processing task %1$s", e); try { verbose("Thread(%1$s): destruction", threadName); mQueueThreadContext.destruction(Thread.currentThread()); } catch (IOException | InterruptedException e) { mLogger.error(e, "Thread(%1$s): %2$s", threadName, e.getMessage());
/** * Shutdowns the working queue and wait until all pending requests have * been processed. This needs to be reviewed as jobs can still be added * to the queue once the shutdown process has started.... * @throws InterruptedException if the shutdown sequence is interrupted */ public synchronized void shutdown() throws InterruptedException { // push as many death pills as necessary for (Thread t : mWorkThreads) { _push(new QueueTask<>(QueueTask.ActionType.Death, null)); } // we could use a latch. for (Thread t : mWorkThreads) { t.join(); } mWorkThreads.clear(); mQueueThreadContext.shutdown(); }