Reputation: 8943
I have an application and it is giving trouble, some of its threads remain in WAITING
stage and some behave normally. All these threads basically have same logic and run multiple instances.
Once I restart the app, then the applications starts working again. The below are two threads, one which is in TIMED_WAITING
and the one which remained in WAITING
stage forever, unless i restart the application.
"Worker-pool-app-c4738262-bfec-47fb-9741-cc8712084508-StreamThread-4-0_14" #62 daemon prio=5 os_prio=0 tid=0x00007f766d71f800 nid=0x11b waiting on condition [0x00007f760af59000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000006c2e0b690> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1081)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
"Worker-pool-app-c4738262-bfec-47fb-9741-cc8712084508-StreamThread-2-0_22" #61 daemon prio=5 os_prio=0 tid=0x00007f76500b5800 nid=0xea waiting on condition [0x00007f760b05a000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000006c25bc550> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
I am not expert in Multithreading , and thread dumps, hence seeking inputs on what might be causing this behaviour. Can anyone provide insight how to look for the clue which is causing the issue.
Upvotes: 2
Views: 521
Reputation: 851
It looks as your application is creating or is using a library which creates a scheduled thread pool executor. As per name thread pool executors delegate work to individual threads. When there is no work to be completed, thread pool executor threads remain dormant until such work is submitted. It looks as this is what you see in your thread dump - thread pool executor threads are waiting for work.
Here is a nice introduction: https://www.baeldung.com/thread-pool-java-and-guava
Upvotes: 1