File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

thread question of Dan Chisholm mock exam

 
Serena Zhou
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following Dan Chisholm question has the answer of a, but why c is not correct? Because join method will force the current executing thread to Ready status as long as the thread that call join is alive. So the join method in Thread will not force a thread to move into the Not-Runnable state. Correct me if I am wrong and thanks!
 
pallavi utukuri
Ranch Hand
Posts: 182
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following Dan Chisholm question has the answer of a, but why c is not correct? Because join method will force the current executing thread to Ready status as long as the thread that call join is alive. So the join method in Thread will not force a thread to move into the Not-Runnable state. Correct me if I am wrong and thanks!
Runnable : once a thread's start() method is called, it is said to be in runnable state. The Runnable state can be thought of as a default state. if a thread is not in any other state, it's in the runnable state
yield : The yield method causes the runtime to context switch from the current thread to the next available runnable thread. This is one way to ensure that threads at lower priority do not get starved.
join : Let an object wait for a thread to complete at a later time Or, Thread.join(long msec) can be used to obtain calls with time-out
"So the join method in Thread will not force a thread to move into the Not-Runnable state. " ..........is proved correct
"join method will force the current executing thread to Ready status as long as the thread that call join is alive."......correct i think
but this leaves me with a confusion Ready state and Runnable state the same?
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but this leaves me with a confusion Ready state and Runnable state the same?

Yes. I have the use of "Ready" and "Runnable" but not at the same time. So I think you can assume they are both names for the same state.
Looking ahead to Java 1.5 there is a new Thread State Enum.
In the case of Thread.join(), the calling thread would not have to leave the running state if the joined to-thread had already finished, it can keep on running. Probably this is an implementation dependent thing.
[ April 18, 2004: Message edited by: Barry Gaunt ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic