The pthreads design provides a sophisticated framework for achieving two other key activities for a robust multithreaded application: the ability to have a thread in the app cancel (effectively, kill) another thread, and the ability to have a thread that is either terminated normally (via the pthread_exit(3)) or abnormally (via cancelation) be able to perform the required resource cleanup.
The following sections deal with these topics.