Background threads consuming 100% CPU on iPhone 3GS causes latent main thread Background threads consuming 100% CPU on iPhone 3GS causes latent main thread multithreading multithreading

Background threads consuming 100% CPU on iPhone 3GS causes latent main thread


In practice you simply cannot have more than two or three background network threads and have the UI stay fully responsive.

Optimize for user responsiveness, it's the only thing a user really notices. Or (and I really hate to say this) add a "Turbo" button to your app that puts up a non-interactive modal dialog and increases concurrent operations to 10 while it is up.


It sounds as though NSOperationQueueDefaultMaxConcurrentOperationCount is set to 1 for a reason! I think you're just overloading your poor phone. You may be able to mess around with threading priorities -- I think the Mach core is available and part of the officially blessed API -- but to me it sounds like the wrong approach.

One of the advantages of using "system" constants is that Apple can tune the app for you. How are you going to tune this to run on an original iPhone? Is 10 high enough for next years quad-core iPhone?


James, although I haven't experienced your problem, what I've had success with is using the synchronous connection for downloading within an NSOperation subclass.

NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&requestError];

I use this approach for grabbing image assets from network locations and updating the target UIImageViews. The download occurs in NSOperationQueue and the method that updates the image-view is performed on the main thread.