Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread State

 
Ahmed Basheer
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic