how to executed code after dispatch_group_notify gcd?
<p>My question is how to <strong>return 0</strong>  after  <strong>dispatch_group_notify</strong> in function ?</p>

<p>if i run code below, it will return 0 right now but not wait every gcd works finished include dispatch_group_notify.</p>

<pre><code>int func() {
  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,^{
    });
    dispatch_group_async(group, queue,^{
    });

    dispatch_group_notify(group, queue, ^{
    });
    return 0;
}
</code></pre>

<p>Now i use a flag in while to wait dispatch_group_notify finished.</p>

<pre><code> dispatch_group_notify(group, queue, ^{
       flag = true;
 });

while(!flag) ;
return 0;
</code></pre>

<p>This is stupid! Any one can help Me, thanks</p>