Hallo MIKE!
Antwort auf eine Message von MIKE RUSKAI an VITUS JENSEN:
VJ>> You can use DosWaitThread so that you can recover thread resources
VJ>> when the thread ends, or to synchronize the execution of a thread
VJ>> with the execution of other threads. === DosWaitThread is used to
VJ>> wait for termination of threads within a process. It is usually used
VJ>> so that thread resources (for example, the stack) can be recovered
VJ>> when a thread ends. ===
MR> FWIW, I compiled a quickie to test this (as I had never used
MR> DosWaitThread()), and the results seem to indicate that resources are
MR> not lost.
MR> So, at the very least, the thread's stack is recovered by the system
MR> as soon as the thread ends, regardless of whether or not
MR> DosWaitThread() is called.
Ive always assumed, that this is historical from OS2 1.x times. here the user
allocates the stack and so the use definitly have to know, when the thread
finally terminated.
but under 2.x times i assumed there is a thread exit routine inserted by the
OS2 itself. and this function should run, when the thread low level
terminates. at this point the thread resources are not need anymore, and so
can savely be freed.
there is one scenario when you loose resources in threads:
create a thread with _beginthread
create C++ objects on the (thread) stack and let the ctors allocate
resources.
then terminate the thread with _endthread (selftermination)
then no destructors are called and so the resources are lost.
Servus, Mario!
--- FleetStreet 1.21 PR#2
2604/104
* Origin: LC/32 Development Team, http://www.kirchnersoft.com (2:310/14.11)
|