Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1.  
  2. \Axvf\Threadable\ProcessControl::killAllThreads();
  3. $Threadables = [];
  4. for ($i=0; $i< 10; $i++) {
  5. $Threadables[] = new ThreadableExample();
  6. }
  7. foreach ($Threadables as $Threadable) {
  8. /**
  9. * @var \Axvf\Threadable\ThreadableInterface $Threadable
  10. */
  11. echo $Threadable->spawnThread() . "\n";
  12. }
  13. sleep(2);
  14. try {
  15. while (count($Threadables) > 0) {
  16. $Rand = array_rand($Threadables);
  17. $Threadable = $Threadables[$Rand];
  18. $Threadable->killThread();
  19. unset($Threadables[$Rand]);
  20. usleep(50000);
  21. }
  22. } catch (\Axvf\Threadable\Exceptions\NoSuchProcessException $Exception) {
  23. echo $Exception->getMessage();
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement