pThread - Threading for PHP
pThreads واقعیه کد PHP: <?phpclass MyClassName extends Thread{ private $classId = NULL; function __construct() { $this->classId = rand(1, 9); retu ; } function run() { for ($i = 1 ; $i < 10; $i ++) { echo ("Object: #{$this->classId} - current executing thread UID: " . $this->getCurrentThreadId() . PHP_EOL); sleep(25); retu ; } }}const THREADS = 4;for ($i = 0; $i < THREADS; $i ++){ $pool[] = new MyClassName();}foreach ($pool as $worker){ if (!$worker->isStarted()) { if (!$worker->start()) { echo 'Error starting thread.'; break; } } else { echo 'The thread is a...
ادامه مطلب