A dispatch group allows an organization thread to know that one or more tasks are completed.
If you have a scenario where the main thread should not continue to run until the task in the queue is finished, you can use dispatch group technology to have one or more queues wait for the execution to complete before returning to the main thread.
The following example shows the basic usage of creating a dispatch group:
dispatch_queue_t queue = Dispatch_get_global_queue (Dispatch_queue_priority_default, 0); dispatch_group_t group = Dispatch_group_create (); Dispatch_group_async (group, queue, ^{//perform some asynchronous work}); Some other processing//waits in the dispatch group, preventing the current thread from continuing to execute dispatch_group_wait (group, dispatch_time_forever);
adding queues and tasks to a group, using method Dispatch_group_async, line 11th calls the Dispatch_group_wait method to wait until the task in all groups is finished before it returns.
------------from iOS app development best Practices
Multi-threaded----Dispatch Group Technology dispatch_group_t