private boolean doWork(boolean blocking) throws InterruptedException { Processing processing; if (blocking) { processing = queue.take(); } else { processing = queue.poll(); } if (processing == null) { //did no work, returning nothing to queue return false; } if (!isInService()) { //did no work, returning processing (because it's not empty) queue.add(processing); //always successful, since queue is unbounded return false; } boolean remove = workOn(processing); //NOTE: Exceptions are handled in here, but not Errors if (!remove) { queue.add(processing); //always successful, since queue is unbounded } return true; //NOTE: We *could* have called returnProcessing() in a finally block here, but we don't //want that, since the only thing being thrown out here is Errors, and then the Processing //can just disappear instead }