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

Can we make main() thread as daemon?

0 Answers  


What is passed by reference and pass by value ?

0 Answers  


This is related to threads. I have a class with synchronized method m1(). Can I create different instances of this class and execute the m1() for different threads?

3 Answers  


What is the difference between array and array list in java?

0 Answers  


What do you mean by buffering?

0 Answers  






Explain about GridBag Layout?

1 Answers  


How are variables stored in memory?

0 Answers  


How can a class be accessed, If no access modifiers are declared?

4 Answers  


what is difference between length and length()?

8 Answers  


Why all programming languages have main as a execution starting point?

4 Answers  


What is the driver class?

0 Answers  


How arrays are stored in memory in java?

0 Answers  


Categories