如何在Eclipse断点中取消对Java testrunner的优先级? [英] How to deprioritize Java testrunner in Eclipse breakpoints?

查看:269
本文介绍了如何在Eclipse断点中取消对Java testrunner的优先级?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我要在Eclipse中调试一些多线程Java代码-具有一个主类RunTest和一个有趣的QueueListener类.

If I am debugging some multithreaded Java code in Eclipse - with a main class RunTest, and an interesting class QueueListener.

假设:

  • 初始化RunTest时-QueueListener在后台运行.
  • RunTest完成时-QueueListener终止
  • RunTest中只有一个方法-带有断点
  • QueueListener中有一个带有断点的方法
  • QueueListener可以一遍又一遍地运行
  • RunTest每次执行仅运行一次(父类)

在Eclipse中调试时-两个断点都出现了.但是Eclipse优先考虑RunTest-我必须通过在调试器中选择该线程,将其手动翻转到QueueListener上,并不断重复执行此操作.

When debugging in Eclipse - both breakpoints come up. But Eclipse gives priority to RunTest - and I have to manually flip it over to the QueueListener by selecting that thread in the debugger - and keep repeating this over and over.

有没有办法告诉Eclipse我对QueueListener更感兴趣,并认为testrunner的优先级较低-当它选择显示调试断点时?

Is there a way to tell Eclipse that I'm more interested in the QueueListener, and consider the testrunner to be a lower priority - when it chooses debug breakpoints to show?

推荐答案

答案可以在ThreadEventHandler方法内的eclipse源代码中找到.有一个挂起的线程队列,如下所示:

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.

这篇关于如何在Eclipse断点中取消对Java testrunner的优先级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆