Analyze and Fix Deadlocks

Analyze Deadlocks

vmlens shows you all detected deadlocks in the Race Conditions, Deadlocks View. To analyze a deadlock expand it, to see the stack traces of the two threads:

export race conditions

In the example above Thread On Start/Stop tries to acquire Monitor@AbstractFileSystem after acquiring Monitor@AbstractFolder. Thread Inactive RequestProcessor tries to acquire the two monitors in reverse order leading to potential deadlock.

Fix Deadlocks

We can fix the deadlock by using tryLock of java.util.concurrent.locks.ReentrantLock instead of monitors.