• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

yield()

 
Jui Mahajan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does the yield() method definitely stop the thread from executing ? I have heards both yes and no as answers to this question. So what is the definite answer ? I have my exam next week, so i want a correct reply this time at least...
also, will questions on threadgroups be asked on the exam ? did any of u guys who have taken the exam lately seen questions on Threadsgroups, suspend(0 and stop() methods etc on ur test ?Thanks
jui
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi:
A call to yield() doesn't gaurantee to do much of anything. It will cause the currently running thread to stop if and only if there are another thread waiting to run with equal or higher priority.
I have taken the exam, and I havn't seen any question on the exam about ThreadGroup.
Good Luck
 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would you like an answer from James Gosling?
"Provides a hint to the scheduler that the current thread need not run at the present time, so the scheduler may choose another thread to run. The scheduler may follow or ignore this suggestion as it sees fit--you can generally rely on the scheduler to "do the right thing" even though there is no specification of exactly what that is"
The Java Programming Language 10.6.1
And how about an answer from Doug Lea?
"Thread.yield is a purely heuristic hint advising the JVM that if there are any other runnable but non-running threads, the scheduler should run one or more of these threads rather than the current thread. The JVM may interpret this hint in any way it likes."
Concurrent Programming in Java 1.1.2.5
 
Gopal Shah
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and this is from Dan ...
The Thread.yield method may cause a thread to move into the ready state. Thread.yield will not cause a thread to move into the not-runnable state.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic