"Bupp Phillips" <
hello@noname.com>wrote in message news:<
e3I9s1WvDHA.2260@TK2MSFTNGP09.phx.gbl>...
Quote
This application has the potential to have possibly 100's or 1000's of
threads running.
This is basically a bad idea, even on a big multi-processors box.
Remember that at any given time, one processor can only run one
thread. Except if your threads are *really* I/O oriented (ie they
spend all of their time waiting for an I/O to complete - but it must
not be the case since you ask for a way to "Sleep" a thread), your
processors are going to spend most of their time switching from one
thread to another and deciding what thread to run next. You should
look for the concept of "thread pool" instead.
Quote
But I don't think a thread will take a megabyte of memory. On my machine,
the "System" process has 33 threads running and its memory consumption is
only 216K.
What do you call "memory consumption"? How do you measure it?
Unless otherwise specified (at compile-time or at thread
creation-time), each thread will have a 1MB space reserved in the
*virtual* address space of the process fot it's stack. It doesn't
means this virtual memory will be commited in real memory immediatly
(if I remember correctly, stack space is commited in 64KB chunks).
However, since you've got 2GB of virtual memory available, minus the
place taken by code, globals and heap, you've got absolutely less than
2000 threads possible per process.
Quote
But thanks for the advance, I will use events to pause and start my threads.
If your threads are in one process, you should better use
CriticalSection, they are less ressource hungry.
Arnaud
MVP - VC
-