Hi pramila: Actually whenever there are equal priority thread then the running thread can volunteerally leave the running state. Hence, it stops its execution.But this behaviour of yield() method is not guarenteed...
Hi: I am sorry for my last post..But I too am confused about this yield() method. I have one Question from Enthuware database that says that "yield() does not necessarily put the calling thread on hold."
The Question was:
In which of the following cases a thread will definitely be alive but not running?? 1. The thread has called wait(). 2. The thread has issued sleep() 3. The thread calls yield() 4. A higher priority thread comes in ready to run state. 5. The thread is trying to enter a synchronized block and the monitor is not free.
Answer are: 1, 2 and 5
According to this concept the yield() does not stop execution. But according to Pramila's Question yield() definitely stops execution.