代码拉取完成,页面将自动刷新
<?php /*
Basic usage
for beginners: it is for command-line only execution. Webservers do not support threads.
*/
require_once("ThreadQueue.php");
// it is the function that will be called several times
function parallel_task($arg){
echo "task with parameter '$arg' starts\n";
sleep( rand(2,5) ); // wait for random seconds
echo "task with parameter '$arg' ENDS\n";
}
// create a queue instance with a callable function name
$TQ = new ThreadQueue("parallel_task");
// add tasks
$TQ->add("one");
$TQ->add("two");
$TQ->add("three");
$TQ->add("four");
$TQ->add("five");
// wait until all threads exit
while( count( $TQ->threads() ) ){ // there are existing processes in the background?
sleep(1); // optional
echo "waiting for all jobs done...\n";
$TQ->tick(); // mandatory!
}
echo "all process finished.\n";
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。