Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Maximum number of threads..

Maximum number of threads..

Scheduled Pinned Locked Moved C / C++ / MFC
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Laing James
    wrote on last edited by
    #1

    Hi. Is there a way to override/redefine the maximum number of threads that can be created by an individual application running on XP. I do not particulary want to redesign my application around thread pools, I just want to know if the default maximum number: 64 on my system, can be increased. Best regards. James.

    G 1 Reply Last reply
    0
    • L Laing James

      Hi. Is there a way to override/redefine the maximum number of threads that can be created by an individual application running on XP. I do not particulary want to redesign my application around thread pools, I just want to know if the default maximum number: 64 on my system, can be increased. Best regards. James.

      G Offline
      G Offline
      Graham Bradshaw
      wrote on last edited by
      #2

      What makes you think 64 is the maximum?

      L 1 Reply Last reply
      0
      • G Graham Bradshaw

        What makes you think 64 is the maximum?

        L Offline
        L Offline
        Laing James
        wrote on last edited by
        #3

        Because in WINNT.H MAXIMUM_WAIT_OBJECTS is defined as 64. If i create a 65th thread, WaitForMultipleObjects() returns with a -1.

        G 1 Reply Last reply
        0
        • L Laing James

          Because in WINNT.H MAXIMUM_WAIT_OBJECTS is defined as 64. If i create a 65th thread, WaitForMultipleObjects() returns with a -1.

          G Offline
          G Offline
          Graham Bradshaw
          wrote on last edited by
          #4

          Laing,James wrote: Is there a way to override/redefine the maximum number of threads that can be created by an individual application running on XP A process can easily create more than 64 threads (just look at Task Manager on a busy server). It's true that MAXIMUM_WAIT_OBJECTS defines the maximum number of handles in the array passed in to WaitForMultipleObjects, but MAXIMUM_WAIT_OBJECTS is not related to how many threads a process can create, which was your original question. Laing,James wrote: I do not particulary want to redesign my application around thread pools Are you actually using thread pools? It sounds like you are, since passing thread handles into WaitForMutlipleObjects is a standard way to implement them. If you are, and you want a to wait on more than 64 threads at one time, rather than create more than 64 threads, I would suggest splitting the array of handles passed in to WaitForMultipleObjects into several smaller arrays (64 or less handles each), and making several calls to WaitForMultipleObjects, one after the other, one for each array.

          L 1 Reply Last reply
          0
          • G Graham Bradshaw

            Laing,James wrote: Is there a way to override/redefine the maximum number of threads that can be created by an individual application running on XP A process can easily create more than 64 threads (just look at Task Manager on a busy server). It's true that MAXIMUM_WAIT_OBJECTS defines the maximum number of handles in the array passed in to WaitForMultipleObjects, but MAXIMUM_WAIT_OBJECTS is not related to how many threads a process can create, which was your original question. Laing,James wrote: I do not particulary want to redesign my application around thread pools Are you actually using thread pools? It sounds like you are, since passing thread handles into WaitForMutlipleObjects is a standard way to implement them. If you are, and you want a to wait on more than 64 threads at one time, rather than create more than 64 threads, I would suggest splitting the array of handles passed in to WaitForMultipleObjects into several smaller arrays (64 or less handles each), and making several calls to WaitForMultipleObjects, one after the other, one for each array.

            L Offline
            L Offline
            Laing James
            wrote on last edited by
            #5

            Thanks for the update. My application creates a new thread as required, so the number maybe considerably more than 64. I had not thought of simply splitting the array of handles. Thanks for the help.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups