Inspectopedia Help

Busy wait

Reports calls to java.lang.Thread.sleep() that occur inside loops.

Such calls are indicative of "busy-waiting". Busy-waiting is often inefficient, and may result in unexpected deadlocks as busy-waiting threads do not release locked resources.

Example:

class X { volatile int x; public void waitX() throws Exception { while (x > 0) { Thread.sleep(10);//warning: Call to 'Thread.sleep()' in a loop, probably busy-waiting } } }

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Java, 241.16690

Last modified: 29 April 2024