By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,441 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,441 IT Pros & Developers. It's quick & easy.

Multithreading

P: n/a
I need a cross-platform way to execute PHP-scripts in multiple threads.
The only way I can think of is to exploit the webserver this way:

1. Store the thread's code in a separate script (e.g. thread.php)
2. Put ignore_user_abort(true) in this script
3. Make a HTTP request for thread.php to the webserver
4. Close the connection immediately
5. Continue in my initial script

Is this the most convenient way of solving the problem, or does anyone
have better solutions for this problem?

--
Tormod Fjeldskår
to****@fritidsproblemer.no
http://tormod.fritidsproblemer.no/
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Can't think of anything better. You might want to keep the connection in
your initial script, since Apache would send a SIG_KILL to PHP, running as
CGI, when the connection gets dropped. Thread.php can use the connection as
a way to communicate its progress back to the initial script. Something like
this:

$thread = fopen("http://localhost/thread.php", "r");
while($s = fgets($thread, 1024)) {
// do some reporting
}
// thread.php is done

Uzytkownik "Tormod Fjeldskår" <to****@online.no> napisal w wiadomosci
news:lZ******************@news4.e.nsc.no...
I need a cross-platform way to execute PHP-scripts in multiple threads.
The only way I can think of is to exploit the webserver this way:

1. Store the thread's code in a separate script (e.g. thread.php)
2. Put ignore_user_abort(true) in this script
3. Make a HTTP request for thread.php to the webserver
4. Close the connection immediately
5. Continue in my initial script

Is this the most convenient way of solving the problem, or does anyone
have better solutions for this problem?

--
Tormod Fjeldskår
to****@fritidsproblemer.no
http://tormod.fritidsproblemer.no/

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.