Re: AfxBeginThread on each user action X or re-use same thread (w CEve



"ultranet" <ultranet@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8E2B9026-0B79-4847-A4B9-C4BB6F820344@xxxxxxxxxxxxxxxx
> What would be a better practice, given that we are on VC 6.0, and don't
> have
> a thread pool? AfxBeginThread obviously is little more robust, cause a
> thread
> death wouldn't have a lasting effect, but re-using the same thread is a
> little more efficient. I'm not seeing isAlive() method in CWinThread, so
> combining the benefits of both isn't straight-forward, it appears.

First the easy part. The m_hThread public member of the class is a handle to
the underlying Win32 thread. Thread handles are synchronization objects and
when they are "signaled" the thread is done. You can test the handle with
any of the wait functions using a timeout of zero to determine if the thread
has exited or not.

As for the question as to best practice - it is trite to say but the number
you need depends on how you intend to use them. If just one will do, don't
create more. And no matter what compiler you use, you will find thread pool
support in Win32 on 2K/XP and 2K+3.

Regards,
Will


.



Relevant Pages