First, what is the GCD full name is the Grand Central Dispatch, the pure C language writing, provides very many powerful function, is the current Apple official website recommended multithreading development method, Nsoperation is based on the GCD package two, the GCD superiority 1, for the multi-core parallel operation proposed The solution 2, GCD will automatically take advantage of more CPU cores, such as dual-core, quad-core 3, GCD can automatically manage the life cycle of threads (create threads, dispatch tasks, Destroy threads) 4, programmers only need to tell gcd what to do, do not write any thread management code three, GCD two core concepts 1, tasks: What to do 2, queue: To hold a task four, the queue can be divided into two major types: 1, serial queue: (Serial Dispatch Que)there can only be one thread, add the actions added to the queue by addingSequential execution sequentially, a task is completed before the next task 2, concurrent queue is executed: (Concurrent Dispatch queue)can have multiple threads, he will put these threads on the available processors, while ensuring advanced task Priority 3, there is a special queue is the home column, the main queue is always only one thread (the main thread), used to perform the main thread operation task Five, take gcd long thread, can be abstracted into two steps 1, find the queue {Home row or serial queue or parallel queue} 2, execute task in queue synchronously or asynchronously six, execute two forms of task in queue 1, synchronize: Only the current thread performs the task,does not haveAbility to open a new thread 2, async: You can perform tasks in a new thread,withAbility to open a new thread Vii. thread task created by GCD four ways to do 1, serial synchronization (main thread) 2, serial async (Child thread) 3, parallel synchronization (child thread) 4, parallel async (child thread)
UI-GCD Threads