note 118129 deleted from thread.join by sobak

From: Date: Thu, 01 Dec 2016 17:44:58 +0000
Subject: note 118129 deleted from thread.join by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207905@lists.php.net to get a copy of this message
Note Submitter: 793722672 at qq dot com ---- /** * 实现多线程的类 */ class synchronized extends Thread { public function run() { $daemon = new SendNoticeAction(); $daemon->main(); } } for ($i = 0; $i < 10; $i++) { $pool[] = new synchronized(); } foreach ($pool as $work) { //在独立线程中执行 run 方法 $work->start(); while ($work->isRunning()) { usleep(10); } //让当前执行上下文等待被引用线程执行完毕 $work->join(); }

« previous php.notes (#207905) next »