• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

thread question of Dan Chisholm mock exam

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic