Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple NSOperationQueues?

I would like to use NSOperations in my application to resolve threading problems. I have read some tutorials and now I know what I have to do, but I have a problem. There is a must to have the same NSOperationQueue in each class. What if I use a new NSOperationQueue in each class. There will be concurrency problems?

like image 685
Infinite Possibilities Avatar asked Jun 18 '26 12:06

Infinite Possibilities


1 Answers

You only have concurrency issues if you access a resource from more than one thread. If your operations do not share some resources you should be fine, even with more than one NSOperationQueue running (NSOperationQueue does internally run more than one thread anyway).

If you share one NSOperationQueue across multiple threads, you should probably synchronize calls to it (using @synchronized(...)).

like image 102
Alfonso Avatar answered Jun 21 '26 06:06

Alfonso