note 118320 added to book.pthreads

From: Date: Tue, 17 Nov 2015 06:17:22 +0000
Subject: note 118320 added to book.pthreads
Groups: php.notes 
Request: Send a blank email to php-notes+get-204166@lists.php.net to get a copy of this message
If you try to test threading, remember to let php think slow: Skript: -- C:\Webserver\htdocs>php mttest.php <?php class My extends Thread{ function run(){ for($i=1;$i<10;$i++){ echo Thread::getCurrentThreadId() . "\n"; sleep(2); // <------ } } } for($i=0;$i<2;$i++){ $pool[] = new My(); } foreach($pool as $worker){ $worker->start(); } foreach($pool as $worker){ $worker->join(); } ?> Output: -- C:\Webserver\htdocs>php mttest.php 6300 5816 6300 5816 6300 5816 6300 5816 6300 5816 6300 5816 6300 5816 6300 5816 6300 5816 If you leave sleep() out, the cpu-time for the threads is long enough to complete the script at once. ---- Server IP: 72.52.91.14 Probable Submitter: 84.151.252.155 ---- Manual Page -- http://php.net/manual/en/book.pthreads.php Edit -- https://master.php.net/note/edit/118320 Del: integrated -- https://master.php.net/note/delete/118320/integrated Del: useless -- https://master.php.net/note/delete/118320/useless Del: bad code -- https://master.php.net/note/delete/118320/bad+code Del: spam -- https://master.php.net/note/delete/118320/spam Del: non-english -- https://master.php.net/note/delete/118320/non-english Del: in docs -- https://master.php.net/note/delete/118320/in+docs Del: other reasons-- https://master.php.net/note/delete/118320 Reject -- https://master.php.net/note/reject/118320 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#204166) next »