none
Sleep and WaitOne RRS feed

  • Question

  • Hi,

    Will Thread.Sleep or WaitHandle.WaitOne release the thread to thread pool or they're just in blocked status that other program can't use that thread?

    Thanks in advance!


    p33

    Tuesday, January 8, 2013 10:06 AM

Answers

  • Hmm, depends what you mean by "release". "that other program can't use that thread" doesn't make much sense, by program I understand process and threads belong to a process, they don't somehow move between processes.

    The managed thread is never "released" in any way until it ends. It is possible that during a sleep/wait the unmanaged thread is detached from the managed thread and used for a different managed thread, but in the same process.

    Tuesday, January 8, 2013 10:20 AM
    Moderator
  • No, the thread is not released to thread pool until it executes all the code. The following instructions just turn the thread into waiting state.

    Tuesday, January 8, 2013 6:16 PM

All replies

  • Hmm, depends what you mean by "release". "that other program can't use that thread" doesn't make much sense, by program I understand process and threads belong to a process, they don't somehow move between processes.

    The managed thread is never "released" in any way until it ends. It is possible that during a sleep/wait the unmanaged thread is detached from the managed thread and used for a different managed thread, but in the same process.

    Tuesday, January 8, 2013 10:20 AM
    Moderator
  • No, the thread is not released to thread pool until it executes all the code. The following instructions just turn the thread into waiting state.

    Tuesday, January 8, 2013 6:16 PM