Home

Awesome

Implementation of PHP Threading

This is PHP-only implementation of threading (using pcntl_fork()).

Requirements

Example

<?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();

TODO