Php-threading is a project mainly written in PHP, based on the MIT license.
Threading implemented in PHP
This is PHP-only implementation of threading (using pcntl_fork()
).
<?php
class myThread extends Thread {
function run() {
$sleep = rand(1, 10);
echo "{$this->name} Sleeping for {$sleep}s\n";
sleep($sleep);
}
function finish() {
echo "{$this->name} Done\n";
}
function stop() {
$this->running = false;
}
}
for ($i = 0 ; $i < 4; $i++) {
new myThread();
}
Threading::join();