$thread){ $array[$key] = $thread; } return $array; } public function stopAll() : int{ $logger = \GlobalLogger::get(); $erroredThreads = 0; foreach($this->getAll() as $thread){ $logger->debug("Stopping " . $thread->getThreadName() . " thread"); try{ $thread->quit(); $logger->debug($thread->getThreadName() . " thread stopped successfully."); }catch(ThreadException $e){ ++$erroredThreads; $logger->debug("Could not stop " . $thread->getThreadName() . " thread: " . $e->getMessage()); } } return $erroredThreads; } }