This is a simple test to show how close and kill works.
<?php
logToFile("start");
$thread = new parallel\Runtime();
$thread->run(function(){
register_shutdown_function ( function(){file_put_contents("shutdown.log",date('Y-m-d H:i:s') . "\t last will");} );
$c=0;
while ($c++ < 20){
sleep(1);
echo $c."|";
file_put_contents("thread.log",date('Y-m-d H:i:s') . "\t" . $c.PHP_EOL, FILE_APPEND);
}
});
sleep(10);
$thread->close();
logToFile("end");
function logToFile($msg){
echo PHP_EOL.$msg.PHP_EOL;
file_put_contents("main.log",date('Y-m-d H:i:s') . "\t" . $msg.PHP_EOL, FILE_APPEND);
}
?>