Inspectopedia Help

Call to 'Thread.sleep()' while synchronized

Reports calls to java.lang.Thread.sleep() methods that occur within a synchronized block or method.

sleep() within a synchronized block may result in decreased performance, poor scalability, and possibly even deadlocking. Consider using wait() instead, as it will release the lock held.

Example:

synchronized (lock) { Thread.sleep(100); }

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023