How to cancel/exit/stop execution of Thread object or thread running in background in IOS

后端 未结 3 1951
有刺的猬
有刺的猬 2020-12-10 09:50

I detaching The thread as given below to do some operation in background

 currentThread = [[NSThread   alloc]initWithTarget:contactServiceselector:@selector(         


        
3条回答
  •  生来不讨喜
    2020-12-10 10:18

    cancel
    Changes the cancelled state of the receiver to indicate that it should exit.

    exit
    Terminates the current thread.

    Check NSThread Class Reference

    For more information about cancellation and operation objects, see NSOperation Class Reference.

    Note: In OS X v10.6, the behavior of the cancel method varies depending on whether the operation is currently in an operation queue. For unqueued operations, this method marks the operation as finished immediately, generating the appropriate KVO notifications. For queued operations, it simply marks the operation as ready to execute and lets the queue call its start method, which subsequently exits and results in the clearing of the operation from the queue.

提交回复
热议问题