https://github.com/krakjoe/pthreads
<?php
class Possibilities extends Thread {
public function __construct($url){
$this->url = $url;
}
public function run(){
/*
* Or use curl, this is quicker to make an example ...
*/
return file_get_contents($this->url);
}
}
$threads = array();
$urls = get_my_urls_from_somewhere();
foreach($urls as $index => $url){
$threads[$index]=new Possibilities($url);
$threads[$index]->start();
}
foreach($threads as $index => $thread ){
if( ( $response = $threads[$index]->join() ) ){
/** good, got a response */
} else { /** we do not care **/ }
}
?>
私の推測では、電子メールを送信するコードを同時に実行するための唯一のオプションであるため、curl multi を使用していると思います。この場合、上記のコードのようなものを使用することはお勧めしません。これははるかに高速で効率的であるため、直接 mail() を呼び出します。
しかし、今では、PHP でスレッド化することができます..お楽しみください :)