很多线程正在等待ForkJoinPool

时间:2018-11-05 10:11:00

标签: java deadlock jstack

我的Java应用程序停止工作。在查看堆栈转储时,我发现有28个线程正在等待特定线程。我在应用程序启动时使用newSingleThreadScheduledExecutor,并在应用程序关闭时将其停止。

我不确定如何从这里继续。是问题的根本原因还是我错过了什么?

"ForkJoinPool.commonPool-worker-29" #1326 daemon prio=5 os_prio=0 tid=0x00007ff8d8054000 nid=0x2644 waiting on condition [0x00007ff87154a000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)

堆栈转储的Grep结果

- parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)
    - parking to wait for  <0x00000000804e10c8> (a java.util.concurrent.ForkJoinPool)

1 个答案:

答案 0 :(得分:0)

ForkJoinPool由并行流操作使用。您应该修改在流上使用parallel()调用的方式(并且可能要重新考虑一下,因为等待意味着阻塞或同步,并且都不应该在并行流中使用)。