How to disarm Java testrunner at Eclipse breakpoints?

If I debug multithreaded Java code in Eclipse - with the main class RunTest and interesting class QueueListener.

Assumptions:

  • When RunTest is initialized, QueueListener starts in the background.
  • When RunTest completes - QueueListener completes
  • RunTest has a single method - with a breakpoint in it
  • QueueListener has a single method with a breakpoint in it.
  • QueueListener can work again and again
  • RunTest runs only once per execution (parent class)

When debugging, both breakpoints appear in Eclipse. But Eclipse gives RunTest priority - and I need to manually flip it to QueueListener by selecting this thread in the debugger - and repeat this over and over again.

Is there a way to tell Eclipse that I am more interested in QueueListener, and consider testrunner to be a lower priority - when it selects debug breakpoints to display?

+7
source share
2 answers

The answer can be found in the eclipse source code in the ThreadEventHandler method. There is a queue of suspended threads, as shown below:

 /** * Queue of suspended threads to choose from when needing * to select a thread when another is resumed. Threads * are added in the order they suspend. */ private Set fThreadQueue = new LinkedHashSet(); 

Further down, every time a breakpoint hits, a paused thread is added to this queue:

 protected void handleSuspend(DebugEvent event) { ... queueSuspendedThread(event); ... } 

Method to get the following suspended stream:

 protected synchronized IThread getNextSuspendedThread() { if (!fThreadQueue.isEmpty()) { return (IThread) fThreadQueue.iterator().next(); } return null; } 

Thus, the answer is no, there is no control over the order; it will be strictly in the order in which each thread hits the breakpoint and is added to the base queue.

+3
source

There is no priority, but it depends only on the time of your application. Your 2 control points probably fall within a very short amount of time, but always in the same order. And then the eclipse will always open the editor (and scroll to the stream) only one of them (where I do not know the exact strategy, but I would have guessed the first breakpoint that occurred).

You really do not want your editors / views to change all the time when debugging a multi-threaded application and hitting breakpoints after a few seconds, or you?

0
source

All Articles