simple.php
<?php
class SimpleThread extends Thread {
public
$name = '';
private
$i = 0;
public function __construct($name) {
$this->name= $name;
$this->i= 0; // workaround
}
public function run() {
for ($this->i= 0; $this->i < 5; $this->i++) {
printf("%d %s\n", $this->i, $this->name);
usleep(rand(1, 4) * 100000);
}
printf("DONE: %s\n", $this->name);
}
}
$k= new SimpleThread('Karlsruhe');
$k->start();
$b= new SimpleThread('Berlin');
$b->start();
$n= new SimpleThread('New York');
$n->start();
sleep(10);
?>