Source:
<code>protected TaskWrapper getNextReadyTask() throws InterruptedException { while (runningThread != null) { TaskWrapper nextHighPriorityTask = highPriorityQueueSet.getNextTask(); TaskWrapper nextLowPriorityTask = lowPriorityQueueSet.getNextTask(); if (nextLowPriorityTask == null) { if (nextHighPriorityTask == null) { LockSupport.park(); } else { long nextTaskDelay = nextHighPriorityTask.getDelay(TimeUnit.MILLISECONDS); if (nextTaskDelay <= 0) { <START> if (nextHighPriorityTask.canExecute()) { <END> return nextHighPriorityTask; } } else { LockSupport.parkNanos(Clock.NANOS_IN_MILLISECOND * nextTaskDelay); } } } else if (nextHighPriorityTask == null) { long nextTaskDelay = nextLowPriorityTask.getDelay(TimeUnit.MILLISECONDS); if (nextTaskDelay <= 0) { if (nextLowPriorityTask.canExecute()) { return nextLowPriorityTask; } } else { LockSupport.parkNanos(Clock.NANOS_IN_MILLISECOND * nextTaskDelay); } } else { long nextHighDelay; long nextLowDelay; ClockWrapper.stopForcingUpdate(); try { nextHighDelay = nextHighPriorityTask.getDelay(TimeUnit.MILLISECONDS); nextLowDelay = nextLowPriorityTask.getDelay(TimeUnit.MILLISECONDS); } finally { ClockWrapper.resumeForcingUpdate(); } if (nextHighDelay <= 0) { if (nextHighDelay <= nextLowDelay || nextLowDelay > maxWaitForLowPriorityInMs * -1) { if (nextHighPriorityTask.canExecute()) { return nextHighPriorityTask; } } else if (nextLowPriorityTask.canExecute()) { return nextLowPriorityTask; } } else if (nextLowDelay <= 0 && nextLowPriorityTask.canExecute()) { return nextLowPriorityTask; } else { if (nextLowDelay < nextHighDelay) { LockSupport.parkNanos(Clock.NANOS_IN_MILLISECOND * nextLowDelay); } else { LockSupport.parkNanos(Clock.NANOS_IN_MILLISECOND * nextHighDelay); } } } if (Thread.currentThread().isInterrupted()) { throw new InterruptedException(); } } return null; }</code><technical_language>sense turn 2 if a while( && loop, add some performance in case run a tasks exec out of us. ( i assume happen here)</technical_language>

Target:
protected TaskWrapper getNextReadyTask() throws InterruptedException { while (runningThread != null) { TaskWrapper nextHighPriorityTask = highPriorityQueueSet.getNextTask(); TaskWrapper nextLowPriorityTask = lowPriorityQueueSet.getNextTask(); if (nextLowPriorityTask == null) { if (nextHighPriorityTask == null) { LockSupport.park(); } else { long nextTaskDelay = nextHighPriorityTask.getDelayInMs(Clock.accurateForwardProgressingMillis()); if (nextTaskDelay > 0) { LockSupport.parkNanos(Clock.NANOS_IN_MILLISECOND * nextTaskDelay); } else if (nextHighPriorityTask.canExecute()) { return nextHighPriorityTask; } } } else if (nextHighPriorityTask == null) { long nextTaskDelay = nextLowPriorityTask.getDelayInMs(Clock.accurateForwardProgressingMillis()); if (nextTaskDelay > 0) { LockSupport.parkNanos(Clock.NANOS_IN_MILLISECOND * nextTaskDelay); } else if (nextLowPriorityTask.canExecute()) { return nextLowPriorityTask; } } else { long now = Clock.accurateForwardProgressingMillis(); long nextHighDelay = nextHighPriorityTask.getDelayInMs(now); long nextLowDelay = nextLowPriorityTask.getDelayInMs(now); if (nextHighDelay <= 0) { if (nextHighDelay > nextLowDelay && nextLowDelay < maxWaitForLowPriorityInMs * -1) { if (nextLowPriorityTask.canExecute()) { return nextLowPriorityTask; } } else if (nextHighPriorityTask.canExecute()) { return nextHighPriorityTask; } } else if (nextLowDelay <= 0) { if (nextLowPriorityTask.canExecute()) { return nextLowPriorityTask; } } else { if (nextLowDelay < nextHighDelay) { LockSupport.parkNanos(Clock.NANOS_IN_MILLISECOND * nextLowDelay); } else { LockSupport.parkNanos(Clock.NANOS_IN_MILLISECOND * nextHighDelay); } } } if (Thread.currentThread().isInterrupted()) { throw new InterruptedException(); } } return null; }