wood burning stoves 2.0
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes yield() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "yield()" Watch "yield()" New topic


Jui Mahajan
Ranch Hand

Joined: Jun 02, 2003
Posts: 62
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<br />scjp1.4
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
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

SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
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
Gopal Shah
Ranch Hand

Joined: May 17, 2003
Posts: 65
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.
I agree. Here's the link: http://aspose.com/file-tools
subject: yield()
It's not a secret anymore!