Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

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 ]
 
Doe, a deer, a female deer. Ray, a pockeful of sun. Me, a name, I call my tiny ad ...
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic