I'm trying to encapsulate a simple multi threading startup and stop process within a class. I thought about making it able to create and control an undefined number of threads, so naturally, a list of pointers came to mind. Unfortunately, CList<CWinThread,CWinThread&> doesnt seem to work, so is there another way to 'List' the pointers for each thread thats been initialized like so:
ThreadPoint = ::AfxBeginThread(... );
ThreadPointList.AddTail(ThreadPoint);
...elsewhere
pointer = ThreadPointList.GetAt(ThreadPointList.FindIndex(Index));
pointer->SuspendThread(); //and etc.
If this doesnt seem proper or efficient, i agree. I'm pretty new at multi threading programming, but i guess there should be a much cleaner way of monitoring and controlling the variably created threads.

How to 'List' pointers to multiple threads?
Colin D
St&#233;phane Beauchemin
Klinsmann
As long as your CWinThread object is not set to m_bAutoDelete=FALSE; it is not save to store the pointer.
Create the thread suspended, if you get a pointer from AfxBeginThread, set auto delete to false, than resume the thread.
You have to delete the CWinThread Object by yourself.
Reason: Your thread might terminate and delete the CWinThread object before you recognize that the thread doen't exist any more.