private void schedule(Runnable task) { if (!started.get() && started.compareAndSet(false, true)) { start(); } long timeoutNanos = timeoutNanos(task); try { boolean offered = timeoutNanos == 0 ? taskQueue.offer(task) : taskQueue.offer(task, timeoutNanos, NANOSECONDS); if (!offered) { throw new RejectedExecutionException("Task: " + task + " is rejected, " + "the taskqueue of " + getName() + " is full!"); } } catch (InterruptedException e) { currentThread().interrupt(); throw new RejectedExecutionException("Thread is interrupted while offering work"); } }
private void process(Runnable task) { processed.inc(); try { task.run(); } catch (Throwable e) { OutOfMemoryErrorDispatcher.inspectOutOfMemoryError(e); logger.severe(getName() + " caught an exception while processing:" + task, e); } }
@Override public void run() { for (; ; ) { try { try { Runnable task = workQueue.take(); process(task); } catch (InterruptedException e) { if (!live) { return; } } } catch (Throwable t) { //This should not happen because the process method is protected against failure. //So if this happens, something very seriously is going wrong. logger.severe(getName() + " caught an exception", t); } } }
@Override public void run() { try { while (live) { try { Runnable task = taskQueue.take(); process(task); } catch (InterruptedException ignore) { // we can safely ignore this exception since we'll check if the // striped executor is still alive in the next iteration of the loop. ignore(ignore); } } } catch (Throwable t) { //This should not happen because the process method is protected against failure. //So if this happens, something very seriously is going wrong. logger.severe(getName() + " caught an exception", t); } }
private void process(Runnable task) { processed.inc(); try { task.run(); } catch (Throwable e) { OutOfMemoryErrorDispatcher.inspectOutOfMemoryError(e); logger.severe(getName() + " caught an exception while processing task:" + task, e); } }