/** * Construct a new instance. * * @param updater the field updater * @param emptyArray an empty array of the target type * @param <T> the type which contains the target field * @param <V> the array value type * @return the new instance */ public static <T, V> AtomicArray<T, V> create(AtomicReferenceFieldUpdater<T, V[]> updater, V[] emptyArray) { Assert.checkNotNullParam("updater", updater); Assert.checkNotNullParam("emptyArray", emptyArray); if (emptyArray.length > 0) { throw Messages.msg.arrayNotEmpty(); } return new AtomicArray<>(updater, emptyArray); }
for (;;) { if (stop) { throw Messages.msg.shutDownInitiated(); throw Messages.msg.noThreadCreated(); throw Messages.msg.cannotAddThread(); executor.execute(task); } else { throw Messages.msg.executionRejected();
/** {@inheritDoc} */ public boolean awaitTermination(final long timeout, final TimeUnit unit) throws InterruptedException { final Lock lock = this.lock; lock.lockInterruptibly(); try { if (workers.contains(Thread.currentThread())) { throw Messages.msg.cannotAwaitWithin(); } final long start = System.currentTimeMillis(); long elapsed = 0L; while (! stop && threadCount > 0) { final long remaining = timeout - elapsed; if (remaining <= 0) { return false; } threadExitCondition.await(remaining, unit); elapsed = unit.convert(System.currentTimeMillis() - start, TimeUnit.MILLISECONDS); } return true; } finally { lock.unlock(); } }
public E next() { if (modCnt != modIdx) { throw Messages.msg.concurrentModification(); } final int pos = this.pos; if (pos >= size) { throw Messages.msg.noSuchElement(); } final E[] elements = ArrayQueue.this.elements; final E value = elements[(tail + pos) % elements.length]; this.pos = pos + 1; return value; }
private void doInterrupt() { if (isInterrupted()) return; Messages.msg.tracef("Interrupting thread \"%s\"", this); try { super.interrupt(); } finally { final InterruptHandler interruptHandler = this.interruptHandler; if (interruptHandler != null) { try { interruptHandler.handleInterrupt(this); } catch (Throwable t) { Messages.msg.interruptHandlerThrew(t, interruptHandler); } } } }
final Semaphore semaphore = limitSemaphore; if (! semaphore.tryAcquire(timeout, unit)) { throw Messages.msg.executionTimedOut(); throw Messages.msg.noThreadCreated();
for (;;) { if (stop) { throw Messages.msg.shutDownInitiated(); throw Messages.msg.noThreadCreated(); throw Messages.msg.cannotAddThread(); final long remaining = deadline - now; if (remaining <= 0L) { throw Messages.msg.executionTimedOut();
} catch (InterruptedException e) { Thread.currentThread().interrupt(); throw Messages.msg.executionInterrupted(); throw Messages.msg.taskLimitReached(); throw Messages.msg.noThreadCreated();
for (;;) { if (stop) { throw Messages.msg.shutDownInitiated(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw Messages.msg.executionInterrupted(); executor.execute(task); } else { throw Messages.msg.executionRejected();
for (;;) { if (stop) { throw Messages.msg.shutDownInitiated(); throw Messages.msg.noThreadCreated(); throw Messages.msg.cannotAddThread();
for (;;) { if (stop) { throw Messages.msg.shutDownInitiated(); throw Messages.msg.executionTimedOut();
private void runTask(Runnable task) { if (task != null) try { taskExecutor.execute(task); } catch (Throwable t) { Messages.msg.executionFailed(t, task); } }
public boolean hasNext() { if (modCnt != modIdx) { throw Messages.msg.concurrentModification(); } return pos < size; }
public void setMaxThreads(final int maxThreads) { Assert.checkMinimumParameter("maxThreads", 0, maxThreads); synchronized (lock) { final int old = this.maxThreads; final int diff = old - maxThreads; if (diff < 0) { limitSemaphore.release(-diff); } else if (diff > 0) { if (! limitSemaphore.tryAcquire(diff)) { throw Messages.msg.cannotReduceMaxBelowCurrent(); } } this.maxThreads = maxThreads; } }
final long remaining = deadline - now; if (remaining <= 0L) { throw Messages.msg.executionTimedOut();
} catch (InterruptedException e) { Thread.currentThread().interrupt(); throw Messages.msg.executionInterrupted();
for (;;) { if (stop) { throw Messages.msg.shutDownInitiated(); throw Messages.msg.noThreadCreated(); throw Messages.msg.cannotAddThread(); final long remaining = deadline - now; if (remaining <= 0L) { throw Messages.msg.executionTimedOut();
} catch (InterruptedException e) { Thread.currentThread().interrupt(); throw Messages.msg.executionInterrupted(); throw Messages.msg.taskLimitReached(); throw Messages.msg.noThreadCreated();
for (;;) { if (stop) { throw Messages.msg.shutDownInitiated(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw Messages.msg.executionInterrupted(); executor.execute(task); } else { throw Messages.msg.executionRejected();
for (;;) { if (stop) { throw Messages.msg.shutDownInitiated(); throw Messages.msg.noThreadCreated(); throw Messages.msg.cannotAddThread();