I'm facing difficulties in analyzing the thread dump of my vaadin 7.0 JAVA application and an integration layer written in spring MVC. There are too many threads in waiting state which is causing applications to slow down during peak hours and causing delays of upto 10 seconds in execution of simple code. Following is the trace which is appearing in waiting threads:-
priority:5 - threadId:0x00007f98b48de800 - nativeId:0x6511 - nativeId (decimal):25873 - state:WAITING
stackTrace:
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000006d5444af0> (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.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
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'm using API polling on many places in my application, following is the code of how I'm doing API polling:-
@Override
public void run()
{
int counter = 1;
while (true)
{
try
{
if (counter == 1)
Thread.sleep(5000);
else
Thread.sleep(10000);
System.out.println("Call Some API");
if (counter == 3)
break;
counter++;
}
catch (Throwable e)
{
new CustomException(e);
}
}
The applications are running on JAVA 1.8.0_65 and tomcat 8.0.5 Can anyone please guide me how can I fix this issue of too many waiting threads or how should I perform analysis for the resolution. For blocked threads I have already figured out the problem and fixed it.