File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Threads and Synchronization and the fly likes Stuck Thread in RUNNABLE state Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Stuck Thread in RUNNABLE state" Watch "Stuck Thread in RUNNABLE state" New topic

Stuck Thread in RUNNABLE state

T. Huy Nguyen
Ranch Hand

Joined: Nov 02, 2010
Posts: 57
We observed this stuck thread in Production server. This is the second time I see something like this: A stuck thread with RUNNABLE state. I can't understand how that can happen.

The server is WebLogic server 10.3 running on Sun JVM.

Has anyone encountered a similar situation? Please share your finding. Many thanks in advance.

My material for SCJP (2008), SCWCD (2010), SCBCD (2010). About me
Henry Wong

Joined: Sep 28, 2004
Posts: 18500

Don't know if this is related, but you may want to synchronize that hashmap -- use Collections.syncrhonziedMap() on it.

I have never seen it stuck in the put() method before, but as described in the other topic, I have seen it stuck in the get() method.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Jelle Klap

Joined: Mar 10, 2008
Posts: 1753

Yeah, the stuck thread issue in relation to java.util.HashMap did ring a bell here too.
There's a blog post somewhere that describes the race condition in its internal resize logic beautifully.
I'll try to find it.

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Jelle Klap

Joined: Mar 10, 2008
Posts: 1753

Here we go:
So the long and short of it is: HashMap is not and was never intended to be a thread-safe collection, so if you manipulate it from mulitple threads without proper synchronization, all bets are off.
I agree. Here's the link:
subject: Stuck Thread in RUNNABLE state
Similar Threads
File Upload using Jsp and servlets...
Error while accessing Pentaho Application
Question from threads. Broken pipe
java.lang.ClassCastException: Model.Employee cannot be cast to Model.Employee