locked
Suspended thread creation and resuming RRS feed

  • Question

  • I want to create two threads, i want to some how make sure that two threads are created and handle is available (not invalid)

    Is it a good idea to create both these threads suspended and resume it

    or some event mechanism will be good?
    Jey
    Thursday, December 3, 2009 5:36 AM

Answers

  • Use CreateThread and specify CREATE_SUSPENDED in its dwCreationFlags parameter.
    CreateThread returns the handle to the thread.

    ResumeThread will resume the suspended state of the thread.


    «_Superman_»
    Microsoft MVP (Visual C++)
    • Marked as answer by Nancy Shao Thursday, December 10, 2009 8:04 AM
    Thursday, December 3, 2009 5:49 AM

All replies

  • hello

    if you use createThread API or _beginthreadex then by looking at the handle they return you could be sure of it unless the thread returns too quikly. in case of _beginthreadex.

    suspend and resume will depend upon the handle you pass. if handle is invalid you have same problem. so you check the handle value returned by API for it.

    regards
    deepak


    Thursday, December 3, 2009 5:46 AM
  • Use CreateThread and specify CREATE_SUSPENDED in its dwCreationFlags parameter.
    CreateThread returns the handle to the thread.

    ResumeThread will resume the suspended state of the thread.


    «_Superman_»
    Microsoft MVP (Visual C++)
    • Marked as answer by Nancy Shao Thursday, December 10, 2009 8:04 AM
    Thursday, December 3, 2009 5:49 AM