I detaching The thread as given below to do some operation in background
currentThread = [[NSThread alloc]initWithTarget:contactServiceselector:@selector(
Your background thread needs to check to see if it has been cancelled, either through the isCancelled
method...
if ([[NSThread currentThread] isCancelled]) {
// do cleanup here
[NSThread exit];
}
You can't kill the thread externally because there is no way to know what state the thread might be in and, thus, killing it would produce indeterminate behavior (imagine if the thread was holding a mutex down in the allocator when it was killed... ouch).