我有一个测试代码,我不明白为什么它会停止。 该脚本仅执行799次转换。
set_time_limit(0);
ini_set('display_errors', 0);
类
class CheckIpThread extends Thread {
private $ip;
public $data = null;
public function __construct ($ip_to_check) {
$this->ip = $ip_to_check;
}
public function run () {
$this->data = th($this->ip);
$this->kill;//This line probably does not matter
}
}
结束课
for($a=0;$a<=2000;$a=$a+100)
{th_($a);}
function th_($co){
$threads = [];
for($a=0;$a<=100;$a++){
$thread = new CheckIpThread($co+$a);
$threads []= $thread;
$thread->start();
}
foreach ($threads as $thread) {
$thread->join();
}
foreach ($threads as $thread) {
echo_($thread->data);
}
}
function th($wsad)
{return $wsad;//}
live viev
function echo_($text,$def=0)
{
ob_flush();
flush();
//usleep(200);
if($def===0)
{var_dump($text);}
if($def===1)
{echo($text);}
echo"</br>";
ob_end_flush();
}
//返回int(0)... int(799)和浏览器等待但没有任何反应
答案 0 :(得分:0)
检查apache错误日志,可能是内存溢出。