Advertisement
P22DX

parallel.php

Jun 12th, 2020
1,086
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.37 KB | None | 0 0
  1. <?php
  2.  
  3. sleep(4);
  4. $count = 100;
  5.  
  6. for ($x = 0; $x < $count; $x++) {
  7.     $runtimes[$x] = new \parallel\Runtime;
  8. }
  9.  
  10. foreach ($runtimes as $runtime) {
  11.     $futures[] = $runtime->run(function () use ($count) {
  12.         echo --$count, PHP_EOL;
  13.         usleep(100000);
  14.     })->done();
  15. }
  16.  
  17. $buff = $count;
  18.  
  19. for ($x = 0; $x < $buff; $x++) {
  20.     echo --$count, PHP_EOL;
  21.     usleep(100000);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement