Thread cancellation APIs

You can use thread cancellation APIs to cause a thread to end prematurely, or to aid in cleanup when a thread is ended (either prematurely or normally). The thread cancellation APIs work together to provide a mechanism for thread cleanup and protecting threaded resources from cancellation. The thread cancellation APIs only provide clean up and protection in relationship to other pthread APIs. You cannot protect from or clean up when a thread ends as a result of your process ending (normally or abnormally), or when the thread ends by some mechanism outside of the pthread API set. Some examples of mechanisms that can terminate a thread that are outside o the pthread API set are the ENDJOB *IMMED CL command, a thread ending from an unhandled exception, or the operator terminating a thread using the work with threads screen (Option 20 from the WRKJOB display).

The table below lists the thread cancelability states, the cancellation types, and the cancellation action. Cancelability consists of three separate states (disabled, deferred, asynchronous) that can be represented by two boolean values. The default cancelability state is deferred.

Cancelability Cancelability State Cancelability Type
disabled PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DEFERRED
disabled PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_ASYNCHRONOUS
deferred PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_DEFERRED
asynchronous PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ASYNCHRONOUS

For information about the examples included with the APIs, see Information about the Pthread API examples.

The thread cancellation APIs are:


[ Back to top | Pthread APIs | APIs by category ]