simple-fork-php icon indicating copy to clipboard operation
simple-fork-php copied to clipboard

extents Process vs implements Runnable

Open shtse8 opened this issue 8 years ago • 0 comments

Any different between these two codes:

class TestRunnable implements Runnable 
{
	private $id = 0;

	public function __construct($id) {
		$this->id = $id;
	}
	
    public function run()
    {
		echo "[".$this->id."]\n";
		sleep(1);
    }
	
}

new Process(new TestRunnable(1));

and

class TestProcess extends Process
{
	private $id = 0;

	public function __construct($id) {
		$this->id = $id;
	}
	
    public function run()
    {
		echo "[".$this->id."]\n";
		sleep(1);
    }
}
new TestProcess (1);

shtse8 avatar Mar 29 '17 17:03 shtse8