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
更新 値を大きくしてエラーを飛ばしました。今度は再び2000に戻っても動作しません。致命的なエラー: 'pthreadsがCheckIpThreadを開始できなかったこと、システムに必要なリソースがないこと、またはシステムに課された制限を超過する可能性があることを'スタックトレース: #0 C:¥xampp¥htdocs¥test¥Benchmark.php(34):Thread-> start() #1 C:\ xampp \ htdocs \ test \ Benchmark.php: xampp \ htdocs \ test \ Benchmark.php(22):th_(900) – Sasiadstar