What is yielding and sleeping? how they different?




Answers were Sorted based on User's Feedback



Answer / ranganathkini

When a thread yields, its execution is paused and loses
ownership of the monitor lock giving other waiting threads a
chance to run.

When a thread sleeps, its execution is paused for the
specified duration during such an idle period, the thread
continues to retain the ownership of the monitor lock.

Is This Answer Correct ?    3 Yes 1 No

Answer / ravikiran

yield() method will suspend all the same priority thread
which is running and gives chance to next thread to run
which is of the same priority
sleep() method will make the thread to sleep for a
particular period of time which is specified in the
argument list

Is This Answer Correct ?    1 Yes 2 No

Post New Answer




More Core Java Interview Questions

When try and catch block is used ?

6 Answers  


How do u provide security in java

3 Answers  


how to pass the parameters to applets?

1 Answers  


Can we override static methods?

18 Answers   Bally Technologies,


why the wait,notify,notifyall methods are placed in object class?these are the thread concepts why these methods are placed in Object class?

2 Answers   Satyam, Global Logic,






What is Unicast and Multicast object? Where we will use?

1 Answers   Scope International,


Explain Connection Pooling?

3 Answers  


Which are thin and thicK wrapper Class's in Java?

1 Answers  


Why do we use public static with the main function in Java?

13 Answers   Infosys, College School Exams Tests,


Difference between Applet & Application?

6 Answers  


can we Connect Applet to Data Base ? with Discriptiom. and also What is Diff. from Applet & Servlet?

1 Answers   Systematix,


Java support call by reference (pass by reference) ?

1 Answers   HCL,






Categories