/** * 添加守护进程 * * $a = 890; * * $pid = daemon(function() use ($a){ * * echo $a; * * sleep(1); * * },function(){ * * echo 456; * * }); * @return int */ function daemon() { $child_threads = func_get_args(); $t = new Thread(); foreach ($child_threads as $child_thread) { $t->daemon($child_thread); } $t->run(); return $t->getpid(); }