Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \Axvf\Threadable\ProcessControl::killAllThreads();
- $Threadables = [];
- for ($i=0; $i< 10; $i++) {
- $Threadables[] = new ThreadableExample();
- }
- foreach ($Threadables as $Threadable) {
- /**
- * @var \Axvf\Threadable\ThreadableInterface $Threadable
- */
- echo $Threadable->spawnThread() . "\n";
- }
- sleep(2);
- try {
- while (count($Threadables) > 0) {
- $Rand = array_rand($Threadables);
- $Threadable = $Threadables[$Rand];
- $Threadable->killThread();
- unset($Threadables[$Rand]);
- usleep(50000);
- }
- } catch (\Axvf\Threadable\Exceptions\NoSuchProcessException $Exception) {
- echo $Exception->getMessage();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement