• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSURLConnection vs. NSThread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSURLConnection vs. NSThread


  • Subject: Re: NSURLConnection vs. NSThread
  • From: Mike Abdullah <email@hidden>
  • Date: Fri, 15 May 2009 00:30:10 +0100

I am not saying that the threads created by NSURLConnection are in any way faster than those created manually. I am saying that NSURLConnection is going to use its own thread internally whatever you do, so throwing another thread into the mix is only adding additional overhead.

As it happens, NSURLConnection's thread implementation is also likely to be more efficient that anyone's custom one because it uses a single thread for all connections. After starting your first URL load, the overhead of creating a fresh thread never happens again.

Mike.

On 14 May 2009, at 23:42, Luke the Hiesterman wrote:

To add to that thought, I should add that even if there is a performance difference, I'd be surprised if it's anything that anyone would notice. It's generally a mistake to assume there's a performance problem with a certain approach until you've actually seen the performance problem. In cases like this, I would say that what makes sense to the programmer, and what makes the most simple code should trump what's fastest unless someone can show a tangible gain in one way over the other.

Luke

On May 14, 2009, at 3:39 PM, Luke the Hiesterman wrote:

Why is it assumed that threads created by NSURLConnection are faster than threads created manually with NSThread?

Luke

On May 14, 2009, at 3:36 PM, Mike Abdullah wrote:

Threads would be unnecessary hassle and probably slower performing.

NSURLConnection maintains its own private thread for performing the work of all open URL connections, even if you are using the synchronous API. By using NSThread, you are just bringing an extra unnecessary thread into the mix (possibly more if you're planning 1 thread per-image) and then have to co-ordinate between it and the main thread. The async NSURLConnection API takes care of that for you already.

The only possible performance bottleneck that a thread might benefit you is turning the downloaded image data into a UIImage. If you find that is being slow, then maybe consider a thread-based solution for that portion of the work.

Mike.

On 14 May 2009, at 21:52, Eric E. Dolecki wrote:

Just curious, but if I am loading images into a UIImageView in table cells
from online URLs, is it better to use NSThread or use async NSURLConnection
to ensure that the scrolling is smooth while images are loaded in?


Eric
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com


Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
@apple.com


This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSURLConnection vs. NSThread (From: "Eric E. Dolecki" <email@hidden>)
 >Re: NSURLConnection vs. NSThread (From: Mike Abdullah <email@hidden>)
 >Re: NSURLConnection vs. NSThread (From: Luke the Hiesterman <email@hidden>)
 >Re: NSURLConnection vs. NSThread (From: Luke the Hiesterman <email@hidden>)

  • Prev by Date: Re: NSURLConnection vs. NSThread
  • Next by Date: Re: NSURLConnection vs. NSThread
  • Previous by thread: Re: NSURLConnection vs. NSThread
  • Next by thread: Re: NSURLConnection vs. NSThread
  • Index(es):
    • Date
    • Thread