Asynchronous requests are scheduled on the run loop and setup as a run loop source, triggering the code automatically only when there is data received from the network (as any socket source).
Synchronous requests running on a NSThread
monopolizes a thread to monitor the incoming data, which is in general quite overkill.
You can always cancel an NSURLConnection
even if it has been executed asynchronously, using the cancel
method.
I bet using the new API that allows to send an asynchronous request on an NSOperationQueue
(+sendAsynchronousRequest:queue:completionHandler:
) uses GCD under the hood and dispatch_source_create
, or something similar, so that it behave the same way as when an NSURLConnection
is scheduled on the run loop, avoiding using an additional thread (watch the WWDC'12 videos that explains why threads are evil and their usage should be minimized), the difference only being that allows you to use a block to be informed upon completion instead of using the delegate mechanism.
Some years ago I created a class that embedded NSURLConnection
asynchronous calls and delegate management into a nice block API (see OHURLLoader on my github) that makes it easier to use (feel free to take a look). I bet the new API that uses NSOperationQueue
s uses the same principle, still doing asynchronous requests on the runloop but allowing you to use blocks instead of having to implement a delegate.