Click to See Complete Forum and Search --> : Max. threads supported in VC++


dennis24
November 30th, 2004, 02:37 AM
Can anyone please tell me how many threads can be supported in a single application? In Delphi for example, the recommended number of threads is 16. Please help.

Gabriel Fleseriu
November 30th, 2004, 03:15 AM
There is no limitation imposed by the language *). There may be limitations imposed by the Operating system.

*) Note that C++ actually doesn't support threads on the language level -- the C++ standard doesn't mention them in any way.

dennis24
November 30th, 2004, 03:33 AM
Thanks Gabriel Fleseriu for your info.

Andreas Masur
November 30th, 2004, 03:41 AM
[ Moved thread ]

MikeAThon
December 1st, 2004, 08:28 PM
There is no limitation imposed by the language *). There may be limitations imposed by the Operating system.


And in fact, the Windows Operating System imposes a limitation defined by the available amount of virtual memory:
The number of threads a process can create is limited by the available virtual memory. By default, every thread has one megabyte of stack space. Therefore, you can create at most 2028 threads. If you reduce the default stack size, you can create more threads. However, your application will have better performance if you create one thread per processor and build queues of requests for which the application maintains the context information. A thread would process all requests in a queue before processing requests in the next queue.

See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createthread.asp

Mike