Reputation: 17785
I am trying to get to the bottom of a threading problem in a web application. I am using Eclipse. The problem is when one thread is a certain stage in a very long winded piece of code, another thread can't go any further even though it should. It has the appearance of a blocked thread. Eclipse has marked it as "stepping". It makes no sense why it has stopped as there are no monitors, semaphores, sychnronization blocks anywhere near the code.
Can I use anything in eclipse to understand any reason why the thread looks like it is being blocked?
I can hit the pause button, which suspends the thread. When I click the resume button, it goes back to "stepping", but can't complete this simple line of code:
long beginTime = System.currentTimeMillis();
Thanks.
Upvotes: 1
Views: 2461
Reputation: 116908
In Eclipse, marking a thread as "Stepping" means that you are stepping through the code, either with step-in or (more likely) step-over, and the thread is blocked somehow either doing some IO, waiting for a synchronization lock, calling wait()
, etc.. Eclipse is not controlling the thread and is waiting for the thread to move past the block before it can continue with the "stepping". Once Eclipse has control back of the thread at the next line, your thread is changed to being "Suspended".
For example, while debugging the following test code:
// i put a break point here
System.out.println("Foo");
Object lock = new Object();
synchronized (lock) {
// when I step over this line, my thread is labeled as "Stepping"
lock.wait();
}
System.out.println("Boo");
Once I step over a method which blocks the thread, the thread gets labeled as "Stepping".
Upvotes: 3
Reputation: 359966
"Stepping" sounds like Eclipse thinks you're "stepping through the code" and currently at that line – that is, you're running in Debug mode. Is there a breakpoint set somewhere that you've missed?
Upvotes: 1