Re: Threading objects

From: Date: Wed, 12 Mar 2003 12:15:17 +0000
Subject: Re: Threading objects
Groups: php.general 
Request: Send a blank email to php-general+get-139266@lists.php.net to get a copy of this message
Kris wrote:
I want to be able to thread objects. I'm not really sure at all where to start. but I want a script where multiple objects are being processed at the same time. I have an example php script <? $a = new sleeper(); $b = new sleeper(); $c = new sleeper(); $a->sleepFor(10); $b->sleepFor(5); $c->sleepFor(1); class sleeper { function sleepFor($num) { sleep($num); echo "sorry I was a sleep for $num \r\n"; } } ?> I want so object $c would print then object $b then object $a as the sleeping time is less and less. Does that make sense? Please ask if you don't understand Thanks for any help you can offer what so ever. Kris
Hi, generally, multithreading (using system threads) within PHP is impossible, AFAIK. Of course running (apache) processes can communicate via shm but it is not multithreading. Your code will be executed sequentially as written. One sleep will start after another ends. There is not known, to me, solution, sorry :(; -- Mirek Novak Anima Publishers, s.r.o. Prilucka 360, Zlin 760 01 Czech Republic tel/fax: +420577219132 GSM:+420603807837 jabber:mirek@njs.netlab.cz ICQ:119499448 AUTO.CZ http://www.auto.cz NEWS.AUTO.CZ http://news.auto.cz FORMULE1.CZ http://www.formule1.cz -- Mirek Novak Anima Publishers, s.r.o. Prilucka 360, Zlin 760 01 Czech Republic tel/fax: +420577219132 GSM:+420603807837 jabber:mirek@njs.netlab.cz ICQ:119499448 AUTO.CZ http://www.auto.cz NEWS.AUTO.CZ http://news.auto.cz FORMULE1.CZ http://www.formule1.cz

« previous php.general (#139266) next »