Reputation: 11
I am using TheadPoolExecutor that executes on a PriorityQueue. I have set a minimum pool size of 5 and max of 50. When we ran the load test, we saw like 10% jump is CPU. The thread dump shows
pool-1-thread-5" prio=3 tid=0x020f69a0 nid=0xa3 waiting on condition [0xb517f000..0xb517f970] at sun.misc.Unsafe.park(Native Method) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:118) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1841) at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:200) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:470) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675) at java.lang.Thread.run(Thread.java:595)
Wondering the prestartAllCoreThreads() that I use in ThreadPoolExecutor will have any performance issue?
TIA
Upvotes: 1
Views: 4608
Reputation: 14378
The sun.misc.Unsafe.park
method is where the threads that are created by the ThreadPoolExecutor will wait until new messages are received. Internally the ThreadPoolExecutor has a queue of Runnable
s that it will farm out to waiting threads. If your system is idle or reasonably quiet, expect to see quite a few threads waiting in this method.
If you are profiling a system, this method will often crop up as a key consumer of time. This is expected if most of the time the threads is waiting for work to do.
Upvotes: 2