Java / Java Multithreading part II
What is busy spinning in Java?
Busy spinning is a waiting strategy in which a thread just wait in a loop, without releasing the CPU just by going to sleep. By not releasing the CPU or suspending the thread, your thread retains all the cached data and instruction, which may be lost if the thread was suspended and resumed back in a different core of CPU.
This is popular in high-frequency low latency programming domain, where programmers are trying for extremely low latency in the range of micro to milliseconds.
private volatile boolean isDone = false; public void waitUntilDone() { while (!isDone) { Thread.sleep(1000); } }
More Related questions...