Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

debugging threads with eclipse

Thread view: 
Ben - 21 Jul 2006 20:52 GMT
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
Matt Humphrey - 21 Jul 2006 23:15 GMT
> How do I debug threads using eclipse?
>
[quoted text clipped - 19 lines]
> 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 matth@ivizNOSPAM.com http://www.iviz.com/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.