wood burning stoves 2.0*
The moose likes Threads and Synchronization and the fly likes How to request monitor info on/from a locked object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "How to request monitor info on/from a locked object" Watch "How to request monitor info on/from a locked object" New topic
Author

How to request monitor info on/from a locked object

Ronald Vermeij
Ranch Hand

Joined: Sep 05, 2009
Posts: 37
Hello Java Guru's
Scenario: The Classic Producer - Cubbyhole - Consumer example from Sun Microsystems



My challenge
I'm writing a "third thread" called "monitor_status".
Via this 3rd thread I want to
- get information out of the (java object) monitor that guards the Cubyhole object.
- to monitor the Thread.status of both the Producer and the Consumer threads.

Via the Thread. getState() Is can see in which status a thread is [new],[runnable][,...], etc...
I have not discovered any "java.lang.Object" Class method that provides access to monitor/lock information.


Question:
1. Is it possible (with the example above) to get information on the status of the monitor / lock on the Cubyhole object?
2. Is it possible to look into the monitors ENTER_queue and WAIT_queue? (to see which calling thread are in which monitor_queue)
or...
3. Do i have to rewrite this example to make use of the "java.util.concurrent.locks" Lock object instead of wait(), notify() methods?


I do have found the java.lang.management.MonitorInfo Class, but i can not find a good example that shows me how to use it.
4. Do you have an code-example on how to use this class?

Thanks for sharing your insight on this java monitor / object lock matter.



 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to request monitor info on/from a locked object
 
Similar Threads
threading access
Producer Consumer question
producer/consumer
threads
Sun tutorial Producer/Consumer