* tell the waiting process we have created symbols and fetch will succeed */ $t = $this; $this->synchronized(function () use($t) { $t->notify(); }); /* wait for the process to be finished with the stream */ $this->synchronized(function () use($t) { $t->wait(); }); } } $thread = new Fetching(); $thread->start(); $thread->synchronized(function ($me) { $me->wait(); }, $thread); /* * we just got notified that there are symbols waiting */ foreach (array("sym", "arr", "obj", "objs", "res") as $symbol) { printf("\$thread->%s: ", $symbol); $fetched = $thread->{$symbol}; if ($fetched) { switch ($symbol) { /* * manual unserialize */ case "objs": var_dump(unserialize($fetched)); break;