debugging threads with eclipse

Discussion in 'Java' started by Ben, Jul 21, 2006.

  1. Ben

    Ben Guest

    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
    Ben, Jul 21, 2006
    #1
    1. Advertising

  2. "Ben" <> wrote in message
    news:e9rbb7$69b$...
    > 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 http://www.iviz.com/
    Matt Humphrey, Jul 21, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris

    Debugging a threads problem

    Chris, Feb 12, 2006, in forum: Java
    Replies:
    2
    Views:
    394
    Chris
    Feb 12, 2006
  2. yoda
    Replies:
    2
    Views:
    415
    =?utf-8?Q?Bj=C3=B6rn_Lindstr=C3=B6m?=
    Aug 1, 2005
  3. threads without threads

    , Aug 27, 2004, in forum: C Programming
    Replies:
    4
    Views:
    379
    William Ahern
    Aug 27, 2004
  4. Pedro Pinto

    Java Threads - Get running threads

    Pedro Pinto, Apr 8, 2008, in forum: Java
    Replies:
    2
    Views:
    1,397
    Arne Vajhøj
    Apr 9, 2008
  5. Une bévue
    Replies:
    0
    Views:
    130
    Une bévue
    Jun 14, 2006
Loading...

Share This Page