CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: worker thread

  1. #1
    Join Date
    Apr 2008
    Posts
    93

    worker thread

    i have created a visual C++ workspace and i uses worker thread method, what i want to ask is what is the maximum number of threads can it runs?

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: worker thread

    That's not a good question because it points to the fact that if you need that many threads, then you don't have a good design.

    Since creating a thread requires a handle, one limit is the max # of handles available on the system. A while back (I think NT4 or Win2K) that used to be around 65K. Of course not all those would be available (because of other apps running, etc.).

    You have a more practical limit of several thousand, but still that doesn't mean that using that many is a good design. Investigate thread pooling via QueueUserWorkItem api.

  3. #3
    Join Date
    Apr 2008
    Posts
    93

    Re: worker thread

    ok the program i have done total need of ten threads but when i put in the last thread coding in i have error when executing the program.

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: worker thread

    It's time to get out the undisputed king of troubleshooters.


    That's right, pull out "the debugger."

    Look for resources shared between threads that aren't synchronized.

  5. #5
    Join Date
    Apr 2008
    Posts
    93

    Re: worker thread

    i can try it but i dont know if i learn the solutions from there

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: worker thread

    Post the code from one of the thread procedures.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured