Q
qjzhu
Gurus,
The SDK Document reads the following for Thread.yield():
* Causes the currently executing thread object to temporarily pause
* and allow other threads to execute.
I don't really understand what this sentence says. What's happening
if a thead calls yield()? Will the thread be hung up instantly?
When will the thread continue to excute? What's the difference between
sleep() and yield()?
The Thinking In Java 3rd is describing yield() like this:
* If you know that you¡¯ve accomplished what you need to in your
* run() method, you can give a hint to the thread scheduling
* mechanism that you¡¯ve done enough and that some other thread
* might as well have the CPU.
What does the "done enough" mean? Any real examples?
And it continues to say:
* yield( ) is useful only in rare situations, and you can¡¯t
* rely on it to do any serious tuning of your application
What's the real usage in those so called 'rare situations'? Why does
anyone feel like to use yield() if you can't rely on it?
Sorry I totally don't understand the context of yield(), could anyone
explain the whole history of it? Thank you very much and sorry for such
a newbie question.
The SDK Document reads the following for Thread.yield():
* Causes the currently executing thread object to temporarily pause
* and allow other threads to execute.
I don't really understand what this sentence says. What's happening
if a thead calls yield()? Will the thread be hung up instantly?
When will the thread continue to excute? What's the difference between
sleep() and yield()?
The Thinking In Java 3rd is describing yield() like this:
* If you know that you¡¯ve accomplished what you need to in your
* run() method, you can give a hint to the thread scheduling
* mechanism that you¡¯ve done enough and that some other thread
* might as well have the CPU.
What does the "done enough" mean? Any real examples?
And it continues to say:
* yield( ) is useful only in rare situations, and you can¡¯t
* rely on it to do any serious tuning of your application
What's the real usage in those so called 'rare situations'? Why does
anyone feel like to use yield() if you can't rely on it?
Sorry I totally don't understand the context of yield(), could anyone
explain the whole history of it? Thank you very much and sorry for such
a newbie question.