Re: Cancelling a python thread (revisited...)



Le Sun, 08 Nov 2009 04:40:26 -0800, sven a écrit :

I really don't get that. If the reason would be that it is too much
work to
implement, then I could accept it.

It would probably be a lot of work and even then it would still be unsafe.

Read for example:
http://msdn.microsoft.com/en-us/library/ms686717%28VS.85%29.aspx

« TerminateThread is a dangerous function that should only be used in the
most extreme cases. You should call TerminateThread only if you know
exactly what the target thread is doing, and you control all of the code
that the target thread could possibly be running at the time of the
termination. For example, TerminateThread can result in the following
problems:

* If the target thread owns a critical section, the critical section
will not be released.
* If the target thread is allocating memory from the heap, the heap
lock will not be released.
* If the target thread is executing certain kernel32 calls when it is
terminated, the kernel32 state for the thread's process could be
inconsistent.
* If the target thread is manipulating the global state of a shared
DLL, the state of the DLL could be destroyed, affecting other users of
the DLL. »

.



Relevant Pages

  • RE: FaxConnectFaxServer slow
    ... program does not need to call TerminateThread(). ... the target thread has no chance to execute any user-mode code and its ... the kernel32 state for the thread's process could be ... If the target thread is manipulating the global state of a shared DLL, ...
    (microsoft.public.win32.programmer.tapi)
  • Re: TMultiReadExclusiveWriteSynchronizer implementation still buggy ?
    ... > In the clean up code after the TerminateThread any locks that are still ... If the target thread owns a critical section, ... the kernel32 state for the thread's process could be ...
    (comp.lang.pascal.delphi.misc)
  • RE: FaxConnectFaxServer slow
    ... I understand your concerns at TerminateThread. ... doing and the target thread doesn't have those dangerous aspects. ... It is better to arrange it in a context so that we ... Sincerely hope that my assistance can satisfy you. ...
    (microsoft.public.win32.programmer.tapi)
  • Re: Monitor Thread In DLL
    ... message that your DLL will receive just before it is unloaded?? ... > I am creating a monitor thread in a WIN32 DLL. ... > atexit() for the EXE ... > ExitProcess-> Kills all active worker threads using TerminateThread(). ...
    (microsoft.public.win32.programmer.kernel)
  • Monitor Thread In DLL
    ... I am creating a monitor thread in a WIN32 DLL. ... atexit() for the EXE ... I really want to avoid having my worker thread killed by TerminateThread(). ...
    (microsoft.public.win32.programmer.kernel)