{"action":"opened","issue":{"url":"https://api.github.com/repos/krakjoe/pthreads/issues/602","repository_url":"https://api.github.com/repos/krakjoe/pthreads","labels_url":"https://api.github.com/repos/krakjoe/pthreads/issues/602/labels{/name}","comments_url":"https://api.github.com/repos/krakjoe/pthreads/issues/602/comments","events_url":"https://api.github.com/repos/krakjoe/pthreads/issues/602/events","html_url":"https://github.com/krakjoe/pthreads/issues/602","id":160690757,"number":602,"title":"Thread in array won't start as expected","user":{"login":"zerustech","id":417412,"avatar_url":"https://avatars.githubusercontent.com/u/417412?v=3","gravatar_id":"","url":"https://api.github.com/users/zerustech","html_url":"https://github.com/zerustech","followers_url":"https://api.github.com/users/zerustech/followers","following_url":"https://api.github.com/users/zerustech/following{/other_user}","gists_url":"https://api.github.com/users/zerustech/gists{/gist_id}","starred_url":"https://api.github.com/users/zerustech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zerustech/subscriptions","organizations_url":"https://api.github.com/users/zerustech/orgs","repos_url":"https://api.github.com/users/zerustech/repos","events_url":"https://api.github.com/users/zerustech/events{/privacy}","received_events_url":"https://api.github.com/users/zerustech/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-16T15:29:24Z","updated_at":"2016-06-16T15:29:24Z","closed_at":null,"body":"*If you know how to write phpt tests, please open a PR with environment information, and your test, this will cause CI to test your issue before a human is able to look*\r\n\r\nEnvironment\r\n==========\r\n\r\n  * PHP: 5.6.14\r\n  * pthreads: 2.0.10\r\n  * OS: Mac OS X 10.11.5\r\n\r\nSummary\r\n======\r\n\r\nUnder special circumstance, thread object in an array won't start as expected.\r\n\r\nReproducing Code\r\n==============\r\n\r\n```php\r\n<?php\r\n\r\nclass Producer extends Thread\r\n{\r\n    private $inventory;\r\n    \r\n    public function __construct($inventory)\r\n    {\r\n        $this->inventory = $inventory;\r\n    }\r\n\r\n    public function run()\r\n    {\r\n        $this->inventory->add('*');\r\n        $this->inventory->report();\r\n    }\r\n}\r\n\r\nclass Inventory extends Threaded\r\n{\r\n    private $queue;\r\n\r\n    public function __construct(Threaded $queue)\r\n    {\r\n        $this->queue = $queue;\r\n    }\r\n\r\n    public function add($product)\r\n    {\r\n        $this->queue[] = $product;\r\n    }\r\n\r\n    public function report()\r\n    {\r\n        $msg = '';\r\n\r\n        foreach ($this->queue as $product) {\r\n            $msg .= $product;\r\n        }\r\n\r\n        echo $msg.\"\\n\";\r\n    }\r\n}\r\n\r\n// This works as expected\r\n/*\r\n$queue = new Threaded();\r\n$inventory = new Inventory($queue);\r\n$p = new Producer($inventory);\r\n$p->start();\r\n$p->join();\r\n*/\r\n\r\n// This does not work\r\n$queue = new Threaded();\r\n$inventory = new Inventory($queue);\r\n$pool = [];\r\n$pool[] = new Producer($inventory);\r\n$pool[0]->start();\r\n```\r\n\r\nExpected Output\r\n=============\r\n\r\n```bash\r\n*\r\n```\r\n\r\nActual Output\r\n============\r\n```bash\r\n```"}}
{"actor":{"display_login":"zerustech"}}