In a Java application, a thread may keep waiting for a long time after executing
Thread.join() or by
take() methods of a BlockingQueue. We also refer such a thread as a blocked thread since it remains blocked until some operation is performed. Sometimes a thread can also be blocked for a certain time by
Thread.sleep(). When a thread is blocked for a long time you may need to take the thread out of the WAITING or TIMED_WAITING state. While writing a Java application, we need to take care that a thread does not remain blocked for too long. The corrective action that needs to be performed in such circumstances depends on the type of task the thread is executing. If the task is cancellable, it is simply aborted and if it is not cancellable then a logic needs to be implemented to enable its execution.