MentorUS Global interview question

What is Busy Spinning? Why Should You Use It in Java?

Interview Answer

Anonymous

10 Aug 2017

One of the interesting multithreading question to senior Java programmers, busy spinning is a waiting strategy, in which a thread just wait in a loop, without releasing the CPU for going to sleep. This is a very advanced and specialized waiting strategy used in the high-frequency trading application when wait time between two messages is very minimal. 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 question is quite popular in high-frequency low latency programming domain, where programmers are trying for extremely low latency in the range of micro to milliseconds. See here more 50+ advanced thread interview questions for experienced programmers.