PHP:调用Thread :: start()时出现浏览器连接错误

时间:2018-06-19 09:10:39

标签: php multithreading php-pthread

我有一个奇怪的问题 我在webapp中实现并行搜索,但是只要我调用start() 对于数组中每个线程的方法,我的连接被浏览器阻止(Firefox 60)

这是一段代码:

// fill values into threads

$threadData[] = new ThreadData(0, SPAN-1, $resPool, $resultingRecords, $docContent);
$threads[] = new TextFinder($threadData[0]);

for($i = 1; $i < NUM_THREADS; $i++) {
    threadData[] = new ThreadData( $threadData[$i - 1]->end + 1, $threadData[$i - 1]->end + SPAN, $resPool, $resultingRecords, $docContent);

    if( ($i == NUM_THREADS - 1) && $threadData[$i]->end != (count($resPool) - 1) )
        $threadData[$i]->end = count($resPool) - 1;

    $threads[] = new TextFinder($threadData[$i]);
}

// start threads
foreach ($threads as $thread) {
    //echo $thread->arg."<br>";
    echo $thread->start() . "<br>";
}   

提前致谢。

0 个答案:

没有答案