I have a Java Application (web-based) that at times shows very high CPU Utilization (almost 90%) for several hours. Linux TOP
command shows this. On application res
Your first approach should be to find all references to Thread.sleep and check that:
Sleeping is the right thing to do - you should use some sort of wait mechanism if possible - perhaps careful use of a BlockingQueue
would help.
If sleeping is the right thing to do, are you sleeping for the right amount of time - this is often a very difficult question to answer.
The most common mistake in multi-threaded design is to believe that all you need to do when waiting for something to happen is to check for it and sleep for a while in a tight loop. This is rarely an effective solution - you should always try to wait
for the occurrence.
The second most common issue is to loop without sleeping. This is even worse and is a little less easy to track down.