Reputation: 5661
I have some multithreaded code and am trying to set up some breakpoints in Eclipse so I can do some debugging.
The breakpoint I want to set is in a class used by all of the threads. However, I only want the breakpoint to be hit when I am in the main thread. Is there a way to do this in Eclipse?
I have tried to use the 'conditional' breakpoint options but cannot get it to work.
Upvotes: 4
Views: 2381
Reputation: 1474
There should be an item Filtering in the breakpoint properties dialog. There, you can limit the breakpoint to specific threads. But this only works when the program is already running since that dialog shows all threads from the running JVM.
Upvotes: 2
Reputation: 2995
Conditional breakpoint approach is good. The condition should looks like: Thread.currentThread().getName().equals("main")
.
If you want to set up a breakpoint for another thread you just have to change "main"
to a thread-specific name, which can be provided via the Thread constructor.
Upvotes: 7
Reputation: 9705
You should be able to set up a conditional breakpoint by using a condition dependent on thread-local data. Two examples:
Thread.currentThread().getName()
,ThreadLocal
.Upvotes: 4