Tuesday, 26 March 2013

What is the difference between yield and sleep methods?

Yield:

1) It causes the high priority threads to pause execution and give the low priority threads a chance to execute.
2) The thread going into waiting queue because of yield method release any locks held by them.

Sleep:

1) It causes the thread on which it is invoked to go into waiting state for some time interval.
2) The thread going into waiting queue because of yield method doesn't release any locks held by it.

No comments:

Post a Comment