In yielding the thread permits
another thread which is waiting in queue to use CPU
time (
i.e execute ) while the current thread goes to the back of the queue ( i.e
in a round robin fashion ).
In sleeping the thread suspends its activity itself by calling the sleep
method. This thread can be made active again by using notify() or
notifyAll() methods.
The major problem with the sleep() approach is that it completely depends
on external threads to "Awaken" it. Such an arrangement is
dead-lock prone and kind of very tough to debug and so it is generally
avoided.
|
No comments:
Post a Comment