How to deprioritize Java testrunner in Eclipse breakpoints?

这一生的挚爱 提交于 2019-12-04 05:11:33

The answer can be found in the eclipse source code within the ThreadEventHandler method. There is a queue of suspended threads, as 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 is hit, the suspended thread is added to this queue:

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

The method to get the next suspended thread is:

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

So the answer is no, there is no control over the order, it will strictly be in the order that each thread hits the breakpoint and is added to the underlying queue.

There is no priority involved, but this just depends on the timing behavior of your application. Probably your 2 breakpoints are hit in a very short amount of time, but always in the same order. And then eclipse will always open the editor (and scroll to the thread) of only one of them (where I don't exactly know the chosen strategy, but I would guess the first breakpoint that occured).

You don't really want to have your editors/views changed all the time when debugging a multithreaded application and hitting breakpoints every some seconds, or do you?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!