#### Cancelability State

A thread's cancelability state is determined by the combination of two substates: general cancelability and asynchronous cancelability. These substates can be set to either CANCEL_ON or CANCEL_OFF by calls to the routines pthread_setcancel( ) and pthread_setasynccancel( ) respectively. A thread's cancelability state is determined by its general and asynchronous cancelability substates, as shown in the following table.

Cancelability State

General Cancelability | Asynchronous Cancelability | Cancelability State
CANCEL_OFF | CANCEL_OFF | disabled
CANCEL_OFF | CANCEL_ON | disabled
CANCEL_ON | CANCEL_OFF | deferred
CANCEL_ON | CANCEL_ON | asynchronous

One awkwardness introduced by this mechanism for setting cancelability state is that threads cannot easily determine their current cancelability state, although pthread_setcancel( ) and pthread_setasynccancel( ) return the previous substates. When a thread is created, the default cancelability state is deferred (general cancelability set to CANCEL_ON, asynchronous cancelability set to CANCEL_OFF). A thread that needs to discover its current cancelability state should explicitly maintain this state in some place where it can be easily queried.

####