| Author |
Count of waiting threads
|
Norm Radder
Ranch Hand
Joined: Aug 10, 2005
Posts: 681
|
|
|
Is there a way to get a count of threads that are waiting on an object's monitor?
|
 |
Nitesh Kant
Bartender
Joined: Feb 25, 2007
Posts: 1638
|
|
|
I am not aware to get that when one uses synchronized block. However, if you are using ReentrantLock then getQueueLength() will give you what you want.
|
apigee, a better way to API!
|
 |
Norm Radder
Ranch Hand
Joined: Aug 10, 2005
Posts: 681
|
|
|
Thanks.
|
 |
Ajay Saxena
Ranch Hand
Joined: Nov 13, 2006
Posts: 154
|
|
I think there's no way to know ,from within a Java program,the size of the wait set (the set containing the threads waiting on the mutex) of an object's monitor when the synchronized block is used,the reason being the fact that the implementation of the synchronization logic,achieved through the synchronized keyword,is internal to the JVM. However it would have been good to have a native method on the java.lang.Object class that could return this wait set count. [ September 04, 2008: Message edited by: Ajay Saxena ]
|
 |
 |
|
|
subject: Count of waiting threads
|
|
|