Wikipedia aptly defines deadlock is a situation in which two or more competing actions are each waiting for the other to finish, and thus neither ever does. If deadlock happens in a JVM, only way to recover from the situation is to restart the JVM.

Example

Here is a sample code which simulates dead lock condition in-between two threads:

If you read the above execution path carefully, FirstThread after executing step #1, it would have moved on to step #2. When it is on step #2, SecondThread would have executed it’s step #1. So by the time FirstThread wakes up and executes it’s step #3 (i.e. trying to acquire Lock2), SecondThread would have already acquired lock on Lock2. Similarly SecondThread executes it’s step #3 (i.e. trying to acquire Lock1), FirstThread has already acquired lock on Lock1. Thus it results in classic deadlock situation. Only way to recover from this situation is restart the JVM.