mirror of
https://github.com/danog/parallel.git
synced 2024-11-27 12:54:55 +01:00
28 lines
492 B
PHP
28 lines
492 B
PHP
|
<?php
|
||
|
require dirname(__DIR__).'/vendor/autoload.php';
|
||
|
|
||
|
use Icicle\Concurrent\Threading\ThreadContext;
|
||
|
use Icicle\Loop;
|
||
|
|
||
|
class Test extends ThreadContext
|
||
|
{
|
||
|
public function run()
|
||
|
{
|
||
|
print "Sleeping for 5 seconds...\n";
|
||
|
sleep(5);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$timer = Loop\periodic(1, function () {
|
||
|
print "Demonstrating how alive the parent is.\n";
|
||
|
});
|
||
|
|
||
|
$test = new Test();
|
||
|
$test->start();
|
||
|
$test->join()->then(function () {
|
||
|
print "Thread ended!\n";
|
||
|
Loop\stop();
|
||
|
});
|
||
|
|
||
|
Loop\run();
|