In this post, let’s discuss how to make threads go into a BLOCKED state. Here is a sample program from the open-source BuggyApp application, which would make threads go into a BLOCKED state.
In this getSomething() method, a thread is put to continuous sleep, i.e., the thread is repeatedly sleeping for 10 minutes again and again.
Stack trace of ‘Thread-19’ will also point out that before getting stuck, this thread has obtained 1 lock, and due to which 9 threads are put in the BLOCKED state.