final long deadline = now + unit.toMillis(timeout); if (deadline < 0L) { executeBlocking(task); return;
public List<Runnable> shutdownNow() { shutdown(); // tasks are never queued return Collections.emptyList(); }
public boolean awaitTermination(final long timeout, final TimeUnit unit) throws InterruptedException { final Lock lock = this.lock; lock.lock(); try { if (! stop) { throw Messages.msg.notShutDown(); } final Date deadline = new Date(clipHigh(unit.toMillis(timeout) + System.currentTimeMillis())); final Condition threadDeath = this.threadDeath; while (! runningThreads.isEmpty() && threadDeath.awaitUntil(deadline)); return runningThreads.isEmpty(); } finally { lock.unlock(); } }
public synchronized void start(final StartContext context) throws StartException { final TimeSpec keepAliveSpec = keepAlive; long keepAlive = keepAliveSpec == null ? Long.MAX_VALUE : keepAliveSpec.getUnit().toMillis(keepAliveSpec.getDuration()); final QueuelessExecutor queuelessExecutor = new QueuelessExecutor(threadFactoryValue.getValue(), JBossExecutors.directExecutor(), handoffExecutorValue.getOptionalValue(), keepAlive); queuelessExecutor.setMaxThreads(maxThreads); queuelessExecutor.setBlocking(blocking); executor = new ManagedQueuelessExecutorService(queuelessExecutor); }
public static QueuelessExecutor createQueuelessExecutor(final ThreadFactory threadFactory, final List<Object> taskFilterObjects, final Executor handoffExecutor, final long idleTimeout) { return new QueuelessExecutor(threadFactory, createTaskFilter(taskFilterObjects), handoffExecutor, idleTimeout); }
@Override public void executeNonBlocking(Runnable task) throws RejectedExecutionException { executor.executeNonBlocking(task); } }
public int getCurrentThreadCount() { return executor.getCurrentThreadCount(); }
<A> void addShutdownListener(final EventListener<A> shutdownListener, final A attachment) { executor.addShutdownListener(shutdownListener, attachment); }
@Override public void executeBlocking(Runnable task) throws RejectedExecutionException, InterruptedException { executor.executeBlocking(task); }
@Override void internalShutdown() { executor.shutdown(); }
public boolean awaitTermination(final long timeout, final TimeUnit unit) throws InterruptedException { final Lock lock = this.lock; lock.lock(); try { if (! stop) { throw Messages.msg.notShutDown(); } final Date deadline = new Date(clipHigh(unit.toMillis(timeout) + System.currentTimeMillis())); final Condition threadDeath = this.threadDeath; while (! runningThreads.isEmpty() && threadDeath.awaitUntil(deadline)); return runningThreads.isEmpty(); } finally { lock.unlock(); } }
@Override public void executeBlocking(Runnable task, long timeout, TimeUnit unit) throws RejectedExecutionException, InterruptedException { executor.executeBlocking(task, timeout, unit); }
public List<Runnable> shutdownNow() { shutdown(); // tasks are never queued return Collections.emptyList(); }
public boolean awaitTermination(final long timeout, final TimeUnit unit) throws InterruptedException { final Lock lock = this.lock; lock.lock(); try { if (! stop) { throw Messages.msg.notShutDown(); } final Date deadline = new Date(clipHigh(unit.toMillis(timeout) + System.currentTimeMillis())); final Condition threadDeath = this.threadDeath; while (! runningThreads.isEmpty() && threadDeath.awaitUntil(deadline)); return runningThreads.isEmpty(); } finally { lock.unlock(); } }
final long deadline = now + unit.toMillis(timeout); if (deadline < 0L) { executeBlocking(task); return;
public List<Runnable> shutdownNow() { shutdown(); // tasks are never queued return Collections.emptyList(); }
final long deadline = now + unit.toMillis(timeout); if (deadline < 0L) { executeBlocking(task); return;