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

StringBuilder s = new StringBuilder("Hello Mom");s.append(",I mean,Mother"); Response.Write(s.ToString()); String s = "Hello Mom"; s+ = ",I mean Mom"; Response.Write(s); Which is faster ? which uses the most memory?

6 Answers   HCL,

What is the Set interface?

2 Answers  

What is an anonymous class?

1 Answers   IBM,

Can we call the Thread.sleep in Synchyronozed block?

5 Answers   Logica CMG,

what is inner class?

6 Answers   HCL,

How does JAVA ClassLoader work?

1 Answers   IBM,

why the equals method can be override?when we override the equals method?

5 Answers  

What are wrapper classes?

11 Answers   Noah Solutions,

What is the difference between Static and final?

1 Answers  

Which method will get invoked first in a stand alone application?

1 Answers  

posted in online test

1 Answers  

________ exception must be either caught or specified in throws class of the method.

1 Answers