wood burning stoves 2.0*
The moose likes Java in General and the fly likes Thread State Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Thread State" Watch "Thread State" New topic
Author

Thread State

Ahmed Basheer
Ranch Hand

Joined: Apr 15, 2004
Posts: 77
If there is the blocking socket read call in a thread, what would be the state of the thread? I would assume the state of the thread to be blocked but it is not. The state of the thread to my surprise is RUNNABLE.

e.g The state of the folloeing thead is RUNNABLE even though the socket is
blocked on read call.Any Observations?

new Thread ()
{
public void run()
{
mSocket.getInputStream().read(tmpBuffer,0,tmpBuffer.length);
}
}.start();

Thanks,
Basheer
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
I suspect the aswwer is that since the Thread is blocked while executing native code, as far as Java is concerned it is still Runnable. I see that in Java 1.5 we have a java.lang.Thread.State Enum - see the JavaDocs for the exact meaning of the various states.
Bill
 
wood burning stoves
 
subject: Thread State
 
Similar Threads
K & B question 6 chapter 9(Threads).
Thread
Wating/blocking/sleeping
blocked state
Runnable state