What are the different ways in which a thread can be cancelled?
Cancellation of a target thread may happen in two different scenarios:
-  Asynchronous cancellation: One thread immediately terminates the target thread is known as asynchronous cancellation. 
 
-  Deferred cancellation: The target thread can periodically check if it should terminate, permitting the target thread an opportunity to terminate itself in an orderly fashion.