Package Proposal: PHP::Thread
| From: | luca\.mariano\@email\.it | Date: | Fri, 17 Oct 2003 14:42:35 +0000 |
| Subject: | Package Proposal: PHP::Thread | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-22770@lists.php.net to get a copy of this message | ||
Hi guys,
I wrote and mantain a PHP class named "Thread", similar to java..lang.Thread.
It requires the pcntl and the shmop extensions to be loaded, so only works under *nix systems.
With this class you can write something like this:
class counter extends Thread {
var $counter;
function counter ($name)
{
$this->Thread($name);
$this->counter = 0;
}
function run()
{
while (true) {
$this->counter++;
print $this->counter."\n";
sleep(1);
}
}
$counter1 = new counter('firstCounter');
$counter2 = new counter('secondCounter');
$counter1->start();
$counter2->start();
And now you have two threads running cuncurrently that do the same thing (this is stupid, just for
example...)..
Please give a look to (unpolished) source code at: http://www.lucamariano.it/packages/threadClass.phps
It's also avaible a simple example at: http://www.lucamariano.it/packages/passing_vars.phps
Thanks,
Luca
--
Email.it, the professional e-mail, gratis per te: http://www.email.it/f
Sponsor:
Vuoi cambiare i tuoi interessi ma non la tua banca?
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=656&d=17-10