![Alok mishra](https://www.crazyengineers.com/img/avatar.jpg)
Member • Sep 13, 2013
Member • Sep 13, 2013
Member • Sep 15, 2013
Member • Sep 15, 2013
Member • Sep 15, 2013
then how does yield() distinguish itself from sleep() ?Jaydip JadhavHey
yeild() method basically causes the currently executing thread object to temporarily pause and allow other threads to execute.
Member • Sep 15, 2013
could you please demonstrate how yield() uses priorities to control thread execution ? I really didnt get your point .Dhaval PujaraIT'S all about thread priorities basically thread have given a priority between 1 to 10 when u r developeing application based on multithreading than there is only way to control the exicution steps by controliing the thread must be exicuted in sequence at there yield() is used ......to maintain the priority of the thread
Member • Sep 15, 2013
Member • Sep 15, 2013
This is an implicit mechanism i.e. how JVM used yield() , i say i want to make a program in which i want to make use of yield() ? What then ?The_Small_kSuppose you have number of threads with different priorities in runnable state and a thread with priority 5 is executing(running state) at the same time a thread came with the priority of 6. So in that case the lower priority thread will be paused(using yeild() method).
So yeild() come into action when a thread with higher priority will come into runnable state. As you can see it has no argument like sleep() so once the thread will be paused using sleep() method it will resume again only when the execution of higher priority thread will be completed or paused(externally).
Member • Sep 15, 2013
Member • Dec 11, 2013