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.