debugging threads with eclipse

B

Ben

How do I debug threads using eclipse?

I have a bug in one of my threads, but I can't step to it for some
reason. Here is an example:


class A{

Thread thread = new thread(B);
thread.start(); //breakpoint1

....
}


class B implements Runnable{

run(){

blah blah // breakpoint 2

}

If I step into (F5) breakpoint 1, it doesn't go into the run method of
class B.

If I try to run to next breakpoint, it just runs till the end of the
program.

Now I know that the thread is executing because I get a partial ouput
from it, but it is incorrect.

So how do I step into a different thread of execution?

Thanks a lot,
Ben
 
M

Matt Humphrey

Ben said:
How do I debug threads using eclipse?

I have a bug in one of my threads, but I can't step to it for some reason.
Here is an example:


class A{

Thread thread = new thread(B);
thread.start(); //breakpoint1

...
}


class B implements Runnable{

run(){

blah blah // breakpoint 2

}

If I step into (F5) breakpoint 1, it doesn't go into the run method of
class B.

That's expected. Start does not call the run method.
If I try to run to next breakpoint, it just runs till the end of the
program.

Now I know that the thread is executing because I get a partial ouput from
it, but it is incorrect.

Your technique is correct--set the breakpoint within the code the thread
will execute. I can't tell why this doesn't work without seeing more of
your code, but I would think it has something to do with run not appearing
as you think it does. Either it's a different run method, or your
breakpoint statements really doesn't get executed.
So how do I step into a different thread of execution?

But the breakpoint on the first statement within the run. If it still
doesn't stop, are you sure you're running with debugging and that it's
really the object you think it is?

Cheers,
Matt Humphrey (e-mail address removed) http://www.iviz.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top