• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

How to request monitor info on/from a locked object

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.



reply
    Bookmark Topic Watch Topic
  • New Topic