In Java, how do I test if an object's monitor is locked? [duplicate]
This question already has an answer here: How do determine if an object is locked (synchronized) so not to block in Java? 7 answers Java: How to check if a lock can be acquired? [duplicate] 3 answers In Java, how do I test if an object's monitor is locked? In other words, given a object obj, does any thread own obj's monitor? I do not care which thread owns the monitor. All I need to test is if ANY thread owns a given object's monitor. Since a thread other than the current thread could own the monitor, Thread.holdsLock( obj ) is not enough as it only checks the current thread. I am trying to