What is yielding and sleeping? how they different?

Answers were Sorted based on User's Feedback

What is yielding and sleeping? how they different?..

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

What is yielding and sleeping? how they different?..

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

What are the Abstract Classes provided by Java?

5 Answers   Oracle,

why java main method is given as static method?

2 Answers  

What is the difference between abstract class and interface?

3 Answers  

how to call a method in different package?

4 Answers  

what models are available for event handling?

1 Answers  

How do u provide security in java

3 Answers  

Differentiate constructor and a method and how are it be used?

7 Answers   Wipro,

How to override a equals() method and what is the use?

1 Answers  

Which collection object is faster to retrieving the data and inserting the data into it.

2 Answers   Virtusa, Jamcracker,

Functionality of JVM?

7 Answers   Infosys,

What is exception and error? and what is the difference between them?

2 Answers  

What are legal modifiers that we can use to declare an inner class?

1 Answers   Infosys,