Meaningless Drivel is fun!*
The moose likes Threads and Synchronization and the fly likes find out if a Thread is blocked / blocking monitor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "find out if a Thread is blocked / blocking monitor" Watch "find out if a Thread is blocked / blocking monitor" New topic
Author

find out if a Thread is blocked / blocking monitor

Skripi Mayer
Greenhorn

Joined: Jun 15, 2004
Posts: 10
Hi,

I'm writing my own Monitor und I'm now implementing JUnit Tests.
Is there any method I can do a test to find out, if a Thread is blocked ?

I found Thread.isAlive(), but it just states the Thread has been started and it is not dead (yet).

I have found 'static java.lang.Thread.holdsLock(Object obj)' but his is just
for the current running Thread...

Is there a way to get some debugging information out of the jvm, to tell me,
which Thread is blocked (where, on what, etc) ?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8843
    
    7

Take a look at the monitoring and management API.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
This Java Specialists Newsletter is about automatic detection of deadlocks. The newsletter explores some pretty deep Java stuff some times.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
Don't get me started about those stupid light bulbs.
 
subject: find out if a Thread is blocked / blocking monitor
 
Similar Threads
Synchronization
Blocked state of Thread
secure web based mail
What exactly happens in a call to Object.wait()
Thread doubt