0 votes
in JAVA by
What is busy spin? Why should you use it?

1 Answer

0 votes
by

Busy spin is one of the technique to wait for events without releasing CPU. It's often done to avoid losing data in CPU cached which is lost if the thread is paused and resumed in some other core. So, if you are working on low latency system where your order processing thread currently doesn't have any order, instead of sleeping or calling wait(), you can just loop and then again check the queue for new messages. It's only beneficial if you need to wait for a very small amount of time e.g. in micro seconds or nano seconds. LMAX Disrupter framework, a high-performance inter-thread messaging library has a BusySpinWaitStrategy which is based on this concept and uses a busy spin loop for EventProcessors waiting on the barrier.

Related questions

+1 vote
asked May 29, 2020 in JAVA by Hodge
0 votes
asked Jan 19, 2020 in AWS by Robindeniel
...