JDI problem - can't get frame stack for sleeping threads
Hi,
I have added a button to our Swing application that lets me get a complete thread dump of our application - I do this by starting the app via JDI and adding a breakpoint on a specific type of exception, which is then deliberately thrown when I press the button. The breakpoint has a suspend policy of SUSPEND_ALL.
This almost works - but for some reason, back in my 'debugger' class,some of the ThreadReference objects for my app give an exception when I try to get their frame stack. Here's an extract of my code:for (Iterator it = vm.allThreads ().iterator (); it.hasNext ();){
ThreadReference tr = (ThreadReference) it.next ();
List frames;
try{
frames = tr.frames ();
}catch (IncompatibleThreadStateException e){
System.err.println ("Oops - " + tr.name () +" is suspended " + tr.isSuspended ());
continue;
}
}
Guess what? I end up seeing lines like "Oops - Thread 1 is suspended true". How can this be?
Using the native stack dump (kill -QUIT) I found that the threads that were exhibiting this behaviour were threads that were in java.lang.Thread.sleep. Can anybody explain why this is and what I can do about it?
Thanks,
R
PS This is RH linux 9.0 - I get the same behaviour with 1.4.1_02-b06 and 1.4.2_02-b03

