Guest User

Untitled

a guest
May 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 KB | None | 0 0
  1. <?php
  2.  
  3. mysql_query("LOCK TABLES flows READ");
  4.  
  5. if (!($pid1 = pcntl_fork())) {
  6.     // Child #1
  7.  
  8.     $result = mysql_query("whatever");
  9.  
  10.     /* ... do processing ... */
  11.  
  12.     die();
  13. }
  14.  
  15. if (!($pid2 = pcntl_fork())) {
  16.     // Child #2
  17.  
  18.     $result = mysql_query("whatever");
  19.  
  20.     /* ... do processing ... */
  21.  
  22.     die();
  23. }
  24.  
  25. // Wait for threads to finish
  26. while (!pcntl_waitpid($pid1, $status, WNOHANG) || !pcntl_waitpid($pid2, $status, WNOHANG)) {
  27.     usleep(100);
  28. }
  29.  
  30. mysql_query("UNLOCK TABLES");
  31. echo "Done.\n";
Add Comment
Please, Sign In to add comment