limit number of threads per process

Is there a way to limit the default (I think 2000) threads a process can open on windows Nt server (probably the same answer will be right on other windows OS's)

If not what is the best way to do so in the process code (e.g. an api to query the number of running threads before opening a new one)

finkelgAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
pjknibbsConnect With a Mentor Commented:
AFAIK there's no way to do either using a simple API call. However, if this is your own program, why not just add a global counter variable, then increment it using InterlockedIncrement() at the start of your thread procedure and decrement it using InterlockedDecrement() at the end? That would then give you a count of how many threads your process was running which you could use any way you wanted.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.