I am developing a (C++) program that during execution of a query may use multiple threads, some of which will be dependent on other threads started by itself or another thread within this query-process. Determining if a specific thread exists depends on specific parameters passed to the thread and this is part of thread-data in a list of active threads. Individual threads may complete quickly while others may take a long time.
To prevent trying to reinvent the wheel, is there some algorithm, pattern or best-practice to handle marshaling and waiting on multiple interdependent threads?