note 118265 rejected from book.pthreads by cmb
| From: | cmb@php.net | Date: | Wed, 16 Dec 2015 16:07:35 +0000 |
| Subject: | note 118265 rejected from book.pthreads by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-204421@lists.php.net to get a copy of this message | ||
Note Submitter: 312036773 at qq dot com
----
My code is :
<?php
class My extends Thread{
function run(){
for($i=1;$i<10;$i++){
echo Thread::getCurrentThreadId() . "<br/>";
}
}
}
for($i=0;$i<2;$i++){
$pool[] = new My();
}
foreach($pool as $worker){
$worker->start();
$worker->join();
}
?>
The result is :
4076
4076
4076
4076
4076
4076
4076
4076
4076
5760
5760
5760
5760
5760
5760
5760
5760
5760
How can I make it run like below??? Thread switch?
4076
5760
4076
5760
4076
5760
4076
5760
4076
5760
5760