note 118518 added to threaded.from

From: Date: Sat, 19 Dec 2015 12:26:31 +0000
Subject: note 118518 added to threaded.from
Groups: php.notes 
Request: Send a blank email to php-notes+get-204489@lists.php.net to get a copy of this message
These code can't Run! Why????????? class Account extends Thread{ private $balance; public function __construct($balance){ $this->balance = $balance; } public function draw($cost){ if($this->balance >= $cost){ sleep(1); $this->balance -= $cost; echo Thread::getCurrentThreadId() . "Reduce ${cost} successful,now the balance is :" . $this->balance . "<Br/>"; } else echo Thread::getCurrentThreadId() . "Reduce fail,now the balance still is:" . $this->balance . "<Br/>"; } } $account = new Account(200); for($i=0;$i<3;$i++){ $ts[] = Threaded::from(function(){ $this->account->draw(80); },function($account){ $this->account = $account; },[$account]); } $worker = new Worker(); foreach($ts as $t){ $worker->stack($t); } $worker->start(); ---- Server IP: 72.52.91.14 Probable Submitter: 60.27.236.231 ---- Manual Page -- http://php.net/manual/en/threaded.from.php Edit -- https://master.php.net/note/edit/118518 Del: integrated -- https://master.php.net/note/delete/118518/integrated Del: useless -- https://master.php.net/note/delete/118518/useless Del: bad code -- https://master.php.net/note/delete/118518/bad+code Del: spam -- https://master.php.net/note/delete/118518/spam Del: non-english -- https://master.php.net/note/delete/118518/non-english Del: in docs -- https://master.php.net/note/delete/118518/in+docs Del: other reasons-- https://master.php.net/note/delete/118518 Reject -- https://master.php.net/note/reject/118518 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#204489) next »