In a multithreaded environment, a thread may need to wait for a particular condition to become true. One way of pausing execution in Java is
Thread.sleep(…)
.
If a thread that holds a lock calls Thread.sleep(…)
, no other thread can acquire said lock. This can lead to performance and
scalability issues, in the worst case leading to deadlocks.