throws InterruptedException { long nanos = unit.toNanos(timeout); if (isTerminated()) return true; if (nanos <= 0L) synchronized (this) { for (;;) { if (isTerminated()) return true; if (nanos <= 0L)
throws InterruptedException { long nanos = unit.toNanos(timeout); if (isTerminated()) return true; if (nanos <= 0L) synchronized (this) { for (;;) { if (isTerminated()) return true; if (nanos <= 0L)
throws InterruptedException { long nanos = unit.toNanos(timeout); if (isTerminated()) return true; if (nanos <= 0L) synchronized (this) { for (;;) { if (isTerminated()) return true; if (nanos <= 0L)
/** * Blocks until all tasks have completed execution after a shutdown * request, or the timeout occurs, or the current thread is * interrupted, whichever happens first. * * @param timeout the maximum time to wait * @param unit the time unit of the timeout argument * @return {@code true} if this executor terminated and * {@code false} if the timeout elapsed before termination * @throws InterruptedException if interrupted while waiting */ public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); final ReentrantLock lock = this.submissionLock; lock.lock(); try { for (;;) { if (isTerminated()) return true; if (nanos <= 0) return false; nanos = termination.awaitNanos(nanos); } } finally { lock.unlock(); } }
throws InterruptedException { long nanos = unit.toNanos(timeout); if (isTerminated()) return true; if (nanos <= 0L) synchronized (this) { for (;;) { if (isTerminated()) return true; if (nanos <= 0L)
throws InterruptedException { long nanos = unit.toNanos(timeout); if (isTerminated()) return true; if (nanos <= 0L) synchronized (this) { for (;;) { if (isTerminated()) return true; if (nanos <= 0L)
throws InterruptedException { long nanos = unit.toNanos(timeout); if (isTerminated()) return true; if (nanos <= 0L) synchronized (this) { for (;;) { if (isTerminated()) return true; if (nanos <= 0L)
/** * Blocks until all tasks have completed execution after a shutdown * request, or the timeout occurs, or the current thread is * interrupted, whichever happens first. * * @param timeout the maximum time to wait * @param unit the time unit of the timeout argument * @return {@code true} if this executor terminated and * {@code false} if the timeout elapsed before termination * @throws InterruptedException if interrupted while waiting */ public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); final ReentrantLock lock = this.submissionLock; lock.lock(); try { for (;;) { if (isTerminated()) return true; if (nanos <= 0) return false; nanos = termination.awaitNanos(nanos); } } finally { lock.unlock(); } }
throws InterruptedException { long nanos = unit.toNanos(timeout); if (isTerminated()) return true; if (nanos <= 0L) synchronized (this) { for (;;) { if (isTerminated()) return true; if (nanos <= 0L)
/** * Blocks until all tasks have completed execution after a shutdown * request, or the timeout occurs, or the current thread is * interrupted, whichever happens first. * * @param timeout the maximum time to wait * @param unit the time unit of the timeout argument * @return {@code true} if this executor terminated and * {@code false} if the timeout elapsed before termination * @throws InterruptedException if interrupted while waiting */ public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); final ReentrantLock lock = this.submissionLock; lock.lock(); try { for (;;) { if (isTerminated()) return true; if (nanos <= 0) return false; nanos = termination.awaitNanos(nanos); } } finally { lock.unlock(); } }
@Override public ForkJoinPoolMonitor.Status getStatus() { final ForkJoinPool fjPool = fjPool(); if (fjPool.isTerminated()) // Returns true if all tasks have completed following shut down. return ForkJoinPoolMonitor.Status.TERMINATED; if (fjPool.isTerminating()) // Returns true if the process of termination has commenced but not yet completed. return ForkJoinPoolMonitor.Status.TERMINATING; if (fjPool.isShutdown()) // Returns true if this pool has been shut down. return ForkJoinPoolMonitor.Status.SHUTDOWN; if (fjPool.isQuiescent()) // Returns true if all worker threads are currently idle. return ForkJoinPoolMonitor.Status.QUIESCENT; return ForkJoinPoolMonitor.Status.ACTIVE; }
@Override public Status getValue() { final ForkJoinPool fjPool = fjPool(); if (fjPool.isTerminated()) // Returns true if all tasks have completed following shut down. return ForkJoinPoolMonitor.Status.TERMINATED; if (fjPool.isTerminating()) // Returns true if the process of termination has commenced but not yet completed. return ForkJoinPoolMonitor.Status.TERMINATING; if (fjPool.isShutdown()) // Returns true if this pool has been shut down. return ForkJoinPoolMonitor.Status.SHUTDOWN; if (fjPool.isQuiescent()) // Returns true if all worker threads are currently idle. return ForkJoinPoolMonitor.Status.QUIESCENT; return ForkJoinPoolMonitor.Status.ACTIVE; } });