Saturday, April 18, 2015

STUCK Thread in Java (Most of the time it happens in Production)



                     STUCK Thread in Java

What is Struck Thread: A Stuck Thread means a thread is blocked and is not returning to thread pool in a given time.
Reasons: A thread might be blocked for following reasons:
        a) Infinite loop
        b) Internal Dead Lock
        c)  Heavy I/O connections.

 Mostly this problem happens in the production. 
A Weblogic Stuck Thread means a thread performing  the same request for very long time and more than the configurable Stuck Thread MAX time.

Examples for the Stuck Thread problem: 
while(true){
 //some code which runs in infinite time and does not exit this loop.
}


 (or)

while(true){
 try{
  Thread.sleep(10000);
 } catch (Exception exception){
  break;
 }
}

Or you could lock it on a monitor:

while(true){
new Object().wait();
}


In Weblogic scenarios:
A Weblogic stuck thread simply means a thread performing the same request for a very long time and more than the configurable Stuck Thread Max Time.
Most of the problems happen when the Thread execution is reaching the application or business layer.

At this point your application Java code modules will be performing a lot of business logics, including sending and receiving data from external sources such as a Web Service or an Oracle database for example. Any problem with such external system will cause the Thread to hang and wait for data to come back.

Please provide your inputs or comments or suggestions to make it better.


No comments:

Post a Comment