The exact answer asked by erickson [ here ]
Question: Programmatically determine which Java thread holds a lock?
Answer:
You can only find out, the thread has a normal lock (Thread.holdsLock (object)). You cannot get a link to a thread that has a lock without inline code.
However, if you are doing something complicated with threading, you might want to check out java.util.concurrent packages. ReentrantLock allows you to get its owner (but its protected method, so you have to distribute this). Depending on your application, it is entirely possible that using concurrency packages, you will be sure that you do not need a lock owner in the end.
There are no software methods for finding lock owners, such as the JVM signaling the release of a dump stream in stderr, which are useful for determining the cause of deadlocks.
By the way, please take a look at the following link. It provides all the information about flow related aspects:
source share