title: Intel TBB using task_group to do a Bitonic Sort
body: <p>I'm implementing a bitonic sort using intel TBB. When using the <strong>parallel_invoke</strong> method all goes well. But when using task_group(without calling the wait method), the output is not sorted. When using task_group as below the program does not terminate.</p>
  
  <pre><code>void bitonic_merge(bool up, int array[],int size){
    if(size==1){
        return;
    }
    int m = greatestPowerOfTwoLessThan(size);
    bitonic_compare(up, array, size - m, m);
    g-&gt;run(Bitonic_Merge(up, array , m));
    g-&gt;run(Bitonic_Merge(up, &amp;array[m],size - m));
    g-&gt;wait();
    return;    
  }
  </code></pre>
  
  <p>Can someone see what is wrong? What is the difference between parallel_invoke and using task_group? Also what is better to use in such a situation? The         <strong>parallel_invoke</strong> or <strong>task_group</strong>? Or should I use some other method?</p>
  
  <p>Thanks in advance</p>