【问题标题】:Why is ThreadPoolExecutor.run() being invoked? [duplicate]为什么调用 ThreadPoolExecutor.run()? [复制]
【发布时间】:2012-07-30 14:29:44
【问题描述】:

可能重复:
Eclipse debugger always blocks on ThreadPoolExecutor without any obvious exception, why?

Eclipse 在 finally 块中的以下行中不断暂停 run() 方法中的执行:workDone(this);

我没有在此处设置任何断点,我的应用似乎按预期运行。

关于为什么会发生这种情况的任何指针?

   java.util.concurrent.ThreadPoolExecutor

   public void run() {
        try {
            Runnable task = firstTask;
            firstTask = null;
            while (task != null || (task = getTask()) != null) {
                runTask(task);
                task = null;
            }
        } finally {
            workerDone(this);
        }
    }
}

【问题讨论】:

  • 请展示一个简短但完整的程序来说明问题。
  • workerDone 是做什么的?

标签: java eclipse debugging


【解决方案1】:

您的方法调用workerDone 很可能会引发异常,该异常未处理并在run 方法之外冒泡。线程因此突然结束,但 Eclipse 允许您在异常逃逸方法之前检查这种情况。这是一个自动的“异常断点”。

【讨论】:

    猜你喜欢
    • 2013-11-21
    • 2019-04-15
    • 2019-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-21
    相关资源
    最近更新 更多