/**
* 实现多线程的类
*/
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();
}