Very simply, is there a one to one connection between a thread(or NSThread) and an NSOperation? Or is it abstracted out an operation is kind of a task that can be picked up and run by multiple threads in the background?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Not a one-to-one connection, no. The advantage of using
NSOperationsubclasses is that you’re not required to manage the multi-threading yourself. Apple even (confusingly) defines the typicalNSOperationsubclass (i.e., one overriding the-mainmethod) as non-concurrent, not because it doesn’t support concurrency, but because the details of concurrency are managed by the superclass:In that sense, an
NSOperationsubclass is much more like the target object of NSThread’sdetachNewThreadSelector:toTarget:withObject:.The alternative, if you want control over how the concurrency behaves, is to override
-startand set up concurrency as needed before invoking-main.Here’s a very good overview: Managing Concurrency with NSOperation