1
0
mirror of https://github.com/danog/parallel.git synced 2024-11-27 12:54:55 +01:00
parallel/examples/thread.php

28 lines
492 B
PHP
Raw Normal View History

2015-07-14 00:30:59 +02:00
<?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();