up_to = 0; } public function countToOneThousand() { $pid = pcntl_fork(); if($pid < 0) throw new Exception('No fork for you!'); else if(!$pid) { //THIS IS THE CHILD PROCESS for($i = 1;$i <= 1000;$i++) $this->up_to = $i; } else if($pid) { //THIS IS THE PARENT PROCESS while($this->up_to < 1000) echo($this->up_to."\n"); } } } $mast = new ForkMaster(); $mast->countToOneThousand();