Even if you call pthread_cancel , it is not executed immediately. The processor takes its time to cancel the thread. But, just to mention here: using asynchronous undo or immediate undo is not recommended. I ran into a problem when my application crashed while canceling when using pthread_setcanceltype () as PTHREAD_CANCEL_ASYNCHRONOUS. I really could not find the reason. As far as I know, and even I searched a lot for this while debugging the crash script, we donโt have a confirmation method at which point the thread is canceled.
source share