To help bring clarity, let's take an example: let's say that the main thread of an application creates two worker threads, A and B. Now, the main thread wants to cancel thread A.
The API to request cancelation upon a target thread (A, here) is the following:
int pthread_cancel(pthread_t thread);
The thread parameter is the target thread—the one we are (politely) requesting to please go and die, thank you very much.
But, you guessed it, it's not as simple as that: the target thread has two attributes (that it can set) that determine whether and when it gets canceled:
- Cancelability state
- Cancelability type