@Override public void shutdown(final boolean waitForJobsToComplete) { nexusExecutorService.shutdown(); if (waitForJobsToComplete) { try { nexusExecutorService.awaitTermination(5L, TimeUnit.SECONDS); } catch (InterruptedException e) { throw Throwables.propagate(e); } } }
@Override public boolean runInThread(final Runnable runnable) { try { // this below is true as we do not use queue on executor // combined with abort policy. Meaning, if no exception, // the task is accepted for execution nexusExecutorService.submit(runnable); return true; } catch (RejectedExecutionException e) { return false; } }
public QuartzThreadPool(final int poolSize) { checkArgument(poolSize > 0, "Pool size must be greater than zero"); this.threadPoolExecutor = new NexusThreadPoolExecutor( poolSize, poolSize, 0L, TimeUnit.MILLISECONDS, new SynchronousQueue<Runnable>(), // no queuing new NexusThreadFactory("qz", "nx-tasks"), new AbortPolicy()); // wrapper for Shiro integration this.nexusExecutorService = NexusExecutorService.forFixedSubject(threadPoolExecutor, FakeAlmightySubject.TASK_SUBJECT); }