| 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.
|
 |
 |
|
|
subject: How to request monitor info on/from a locked object
|
|
|