Across the course of my programs execution a number of threads are started, the amount varies depending on user defined settings but they are all running the same method with different variables.
In some situations, a clean up is required mid execution, part of this is stopping all the threads, I don't want them stop immediately though, I just set a variable that they check for that terminates them. The problem is that it can be up to 1/2 second before the thread stops but before the clean up continues I need to be sure that all threads have stopped. The cleanup is executed from another thread so really I need this thread to wait for the others.
I have though of several ways of doing this but they all seem to be overly complex. I was hoping there would be some method that can wait for a group of threads to complete. Does anything like this exist?
Thanks.