在ThreadPoolExecutor的源代码中搜索特定的代码行

时间:2015-01-11 04:04:51

标签: java threadpool threadpoolexecutor

目标

我想在ThreadPoolExecutor的源代码中找到特定的代码行。

当任务提交给ThreadPoolExecutor时,如果池中的所有其他线程都忙,则会创建一个线程。有人可以带我到ThreadPoolExecutor的源代码中的那些代码行,在那里检查池中的所有其他线程是否忙,如果忙,则在空闲时创建新线程,然后将任务切换到空闲线程?

1 个答案:

答案 0 :(得分:0)

源代码可在OpenJDK mercurial repository中找到。您感兴趣的位置似乎位于execute()方法中,位于:

http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java#l1318

您可能最好在正确配置的IDE中打开它,这样您就可以更轻松地在源代码中导航。

相关问题