Maximum number of threads..
-
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.
-
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.
What makes you think 64 is the maximum?
-
What makes you think 64 is the maximum?
Because in WINNT.H MAXIMUM_WAIT_OBJECTS is defined as 64. If i create a 65th thread, WaitForMultipleObjects() returns with a -1.
-
Because in WINNT.H MAXIMUM_WAIT_OBJECTS is defined as 64. If i create a 65th thread, WaitForMultipleObjects() returns with a -1.
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 toWaitForMultipleObjects
, butMAXIMUM_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 toWaitForMultipleObjects
into several smaller arrays (64 or less handles each), and making several calls toWaitForMultipleObjects
, one after the other, one for each array. -
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 toWaitForMultipleObjects
, butMAXIMUM_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 toWaitForMultipleObjects
into several smaller arrays (64 or less handles each), and making several calls toWaitForMultipleObjects
, one after the other, one for each array.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.