What is the difference between yield() and sleep()?

What is the difference between yield() and sleep()?

Thread.sleep(1000) method hands over the control to other thread for a particular time period. Whereas Thread.yield() method causes the currently executing thread object to temporarily pause and allow other threads to execute according to the scheduling algorithm the CPU is running on.

By:Jalees
Date:2014-01-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher