Java – Deadlock

Deadlock in multithreading is a situation where two or more than two are a lock, waiting for each other.

When the first thread needs to use the same lock or wait for the object lock which is acquired by a second thread and second thread also wait for the lock acquired by a first thread then the deadlock occurs because they are waiting for each other which is caused by synchronized keyword.

Example: Java program for Deadlock demonstration.

Output of Deadlock:

Multithreading in java.
Thread Synchronization.
Static Synchronization.
Inter-Thread communication.