0
我有一個測試代碼,我不明白爲什麼它被終止。 該腳本僅執行799次轉換。PHP線程停止工作
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;//}
現場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();
}
//return int(0) ...int(799) and browser waiting but nothing happens
沒有找到錯誤通知。 即使我添加ini_set('memory_limit','2512M');沒有任何變化 – Sasiadstar
我檢查了CLI腳本和邊緣,它的工作原理。但它在我沒有的Chrome瀏覽器中無法使用。 – Sasiadstar
更新 我增加了值並跳過了錯誤。致命錯誤:Uncaught異常'RuntimeException'帶有'pthreads'消息,檢測到CheckIpThread無法啓動,系統缺少必要的資源或系統強加的限制會被超過'在C:\ xampp \ htdocs \ test \ Benchmark.php中:34 堆棧跟蹤: #0 C:\ xampp \ htdocs \ test \ Benchmark.php(34):Thread-> start() #1 C:\ xampp \ htdocs \ test \ Benchmark.php(22):th_(900) – Sasiadstar