Imagine having this code running in a Thread:
while (blockingQueue.size() > 0) {
AbortableCountDownLatch latch = (AbortableCountDownLatch) blockingQueue.poll();
latch.countDown();
}
Thread.sleep(updateinterval * 1000);
How to make the while loop run after the Thread.sleep as an additional execution? As something like:
Thread.sleepAndExecute(Runnable code, sleep time);
So that the code is just executed, after the sleep has entered, not the other way around?
The blockingQueue contains some CountDownLatch, which are blocking another thread. The other thread just is allowed to continue, IF the latches are all countdown AND this thread has entered sleep/await state. Both conditions need to be true so that the other thread is allowed to continue.