Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to kill all the threads which they are not the main thread?

I do many asynchronous execution with blocks in my application.

But I need to kill all the threads which they are not the main thread if a certain event appears in my application.

So is it possible to stop the execution of all blocks ? Or in other terms, kill all the threads which they are not the main thread ?

PS : I tried to execute blocks inside NSOperationQueue, but my first operation does not start at the good time while the followings does.

like image 614
testa abalez Avatar asked Sep 26 '22 18:09

testa abalez


1 Answers

If you need to kill threads to cancel operations, you’re probably doing it wrong. NSOperationQueue or similar solution (like implementing cancellation logic in your blocks) is IMHO the right way to go. If you have some problems with the operation queue, try to sort it out, don’t avoid the problem by creating a worse one.

like image 89
zoul Avatar answered Sep 30 '22 07:09

zoul