%\pagebreak
\section{\kcode{taskgroup} Construct}
\label{sec:taskgroup}
\index{constructs!taskgroup@\kcode{taskgroup}}
\index{taskgroup construct@\kcode{taskgroup} construct}

In this example, tasks are grouped and synchronized using the \kcode{taskgroup} 
construct.

Initially, one task (the task executing the \ucode{start_background_work()} 
routine) is created in the \kcode{parallel} region, and later a parallel tree traversal 
is started (the task executing the root of the recursive \ucode{compute_tree()} 
calls). While synchronizing tasks at the end of each tree traversal, using the 
\kcode{taskgroup} construct ensures that the formerly started background task 
does not participate in the synchronization and is left free to execute in parallel. 
This is opposed to the behavior of the \kcode{taskwait} construct, which would 
include the background tasks in the synchronization.

\cexample[4.0]{taskgroup}{1}

\ffreeexample[4.0]{taskgroup}{1}

