Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Usually, you would prefer the GCD approach.</p> <p>It's simpler when it comes to synchronization/locking than pure threads (NSThread - pthread), and it may be more accurate in a performance perspective.</p> <p>When using pure threads, the problem is you may have performance issues, depending on the number of available cores/processors.</p> <p>For instance, if you have only one core, creating many threads may slow down your application, because the CPU will spend most of its time switching from one thread to another, saving the stack, registers, etc.</p> <p>On the other hand, if you have a lot of cores available, it may be nice to create a lot of different threads.</p> <p>This is where GCD helps, as it manages this for you. It will create the appropriate number of threads, based on the available system resources, to guarantee an optimal utilization, and schedule your actions appropriately.</p> <p>However, for that reason, tasks launched with GCD may not be real-time.</p> <p>So if you REALLY needs that a detached task runs immediately, use an explicit threads. Otherwise, use GCD.</p> <p>Hope this will help you : )</p> <p><strong>EDIT</strong></p> <p>A note about <code>performSelectorInBackground</code>: it simply creates a new thread. So there's basically no difference with the NSThread approach.</p> <p><strong>EDIT 2</strong></p> <p>NSOperation related stuff are a bit different. On Mac OS X, they are implemented using GCD since version 10.6. Previous versions uses threads.</p> <p>On iOS, they are implemented using threads only.</p> <p><strong>Reference</strong></p> <p>All of this is very well explained in the <a href="http://developer.apple.com/library/mac/#documentation/General/Conceptual/ConcurrencyProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008091" rel="noreferrer">Concurrency Programming Guide</a>. It discusses the GCD and thread approaches, with a lot of details about the uses and implementations.</p> <p>If you haven't read it already, you should take a look.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload