/** * Returns the next job or releases a job slot. If a non-null value is returned, the caller must * submit the job to execution. Should only be caller by a caller than currently holds a job slot. * * @return */ private synchronized PrioritizedRequest nextOrRelease() { PrioritizedRequest request = _queue.poll(); if (request == null) { _semaphore.release(); } return request; }