private function waitForAnyThread()
    {
        while (true) {
            foreach ($this->getPIDs() as $pid) {
                if (!$this->isRunning($pid)) {
                    return;
                }
            }

            # If none of the threads have finished let, wait for a second before checking again
            sleep(1);
        }
    }