There are three types of multithreading in iOS, Nstread, NSOPERATION,GCD
This article is about the basic use of GCD.
Usually more use and see is:
0), ^{ // Async Action code block ^{ // Back to the main thread operation code block }) ;
More for updating UI actions
For example, it takes a long time to get the data from the database, and does not want the main thread of the card, put the database data operation in the asynchronous operation code fast, and so on to get the end, callback the main thread, update the UI, in the main thread operation code block to operate
Let's take a look at each of the methods in this code block:
Dispatch_async (< #dispatch_queue_t queue#>, <#^ (void) block#>) represents an asynchronous operation, which corresponds to a dispatch_sync (< #dispatch_queue_t Queue#>, <#^ (void) block#>), synchronous operation, the code in the block executes in order to perform the first parameter in the following action method the dispatch_queue_t queue represents queues, nothing more than two kinds: serial and parallel, in addition to self-built serial or parallel queue to obtain the system serial queue, That is, the main thread serial queue: Dispatch_get_main_queue () Gets the system parallel queue: Dispatch_get_global_queue (Dispatch_queue_priority_default,0The first parameter, which is the queue priority, has four types:#defineDispatch_queue_priority_high 2#defineDispatch_queue_priority_default 0#defineDispatch_queue_priority_low (-2)#defineDispatch_queue_priority_background Int16_minThe self-built queue is processed according to the priority level: Dispatch_queue_create ("com.example.serial", NULL); The first argument, the document specification says: Astringlabel to attach to the queue. This string needs to be unique, usually in the form of the second argument to null or dispatch_queue_serial to represent a serial pass Dispatch_queue_ Concurrent said and the business execution end, must have Dispatch_release (), the queue release
Recently saw an article about GCD, more in-depth, and some do not understand, above I described the content is GCD more basic usage, general procedures are used to these
http://justsee.iteye.com/blog/1883409
Thanks to the author for such in-depth analysis, benefited
iOS Multithreading-GCD basic usage