コード例 #1
0
ファイル: Thread.php プロジェクト: andyongithub/joyplus-cms
<?php

/**
@title:PHP多线程类(Thread)
@version:1.0
@author:axgle <*****@*****.**>
*/
$th = new thread(10);
//10个线程
$th->exec('demo');
//执行自定义的函数
function demo()
{
    fopen('data/' . microtime(), 'w');
}
class thread
{
    var $count;
    function thread($count = 1)
    {
        $this->count = $count;
    }
    function _submit()
    {
        for ($i = 1; $i <= $this->count; $i++) {
            $this->_thread();
        }
        return true;
    }
    function _thread()
    {