This article is from the Threads Programming FAQ, by Bryan O'Sullivan bos@serpentine.com with numerous contributions by others.
Asynchronous cancellation of threads is, in general, evil. The reason
for this is that it is usually (very) difficult to guarantee that the
recipient of an asynchronous cancellation request will not be in a
critical section. If a thread should die in the middle of a critical
section, this will very likely cause your program to misbehave.
Code that can deal sensibly with asynchronous cancellation requests is
"not" referred to as async-safe; that means something else (see the
terminology section of the FAQ). You won't see much code around that
handles asynchronous cancellation requests properly, and you shouldn't
try write any of your own unless you have compelling reasons to do so.
Deferred cancellation is your friend.
 
Continue to: