CrazyEngineers
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Dhaval Pujara

    MemberSep 15, 2013

    IT'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
    Are you sure? This action cannot be undone.
    Cancel
  • Jaydip Jadhav

    MemberSep 15, 2013

    Hey
    yeild() method basically causes the currently executing thread object to temporarily pause and allow other threads to execute.
    Are you sure? This action cannot be undone.
    Cancel
  • Alok mishra

    MemberSep 15, 2013

    Jaydip Jadhav
    Hey
    yeild() method basically causes the currently executing thread object to temporarily pause and allow other threads to execute.
    then how does yield() distinguish itself from sleep() ?
    Are you sure? This action cannot be undone.
    Cancel
  • Alok mishra

    MemberSep 15, 2013

    Dhaval Pujara
    IT'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
    could you please demonstrate how yield() uses priorities to control thread execution ? I really didnt get your point .
    Are you sure? This action cannot be undone.
    Cancel
  • The_Small_k

    MemberSep 15, 2013

    Suppose 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).
    Are you sure? This action cannot be undone.
    Cancel
  • Alok mishra

    MemberSep 15, 2013

    The_Small_k
    Suppose 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).
    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 ?
    Are you sure? This action cannot be undone.
    Cancel
  • Dhaval Pujara

    MemberSep 15, 2013

    yield() is supposed to do is
    make the currently running thread head back to runnable to allow other threads of
    the same priority to get their turn. So the intention is to use yield() to promote
    turn-taking among equal-priority threads. In reality, though, the yield()
    method isn't guaranteed to do what it claims, and even if yield() does cause a
    thread to step out of running and back to runnable, there's no guarantee the yielding
    thread won't just be chosen again over all the others! So while yield() might—and
    often does—make a running thread give up its slot to another runnable thread of the
    same priority, there's no guarantee.
    A yield() won't ever cause a thread to go to the waiting/sleeping/ blocking
    state.
    Are you sure? This action cannot be undone.
    Cancel
  • Ajay Pandey

    MemberDec 11, 2013

    Yield() method pauses the currently running thread giving a chance to excute same priority threads temporarily. If no wating thread or lower priority thread in runnable pool then continue execution of current thread. But its not necessary pause the thread bcos yield() method is platform dependent. May differ from one os to another os.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register