} public function getResult() { return $this->synchronized(function () { while (!$this->result) { $this->wait(); } return $this->result; }); } public static function of(Closure $closure, array $args = []) { $future = new self($closure, $args); $future->start(); return $future; } protected $owner; protected $closure; protected $args; protected $result; } /* some data */ $test = ["Hello", "World"]; /* a closure to execute in background and foreground */ $closure = function ($test) { return $test; }; /* make call in background thread */ $future = Future::of($closure, [$test]); /* get result of background and foreground call */ var_dump($future->getResult(), $closure($test));