Thread::globally

(PECL pthreads < 3.0.0)

Thread::globally执行

Warning

pthreads v3 中已移除此方法。

说明

public static Thread::globally ( void ) : mixed

在全局范围中执行代码块

参数

此函数没有参数。

返回值

被调用代码块的返回值

范例

Example #1 在全局范围执行代码块

<?php
class My extends Thread {
    public function 
run() {
        global 
$std;
        
        
Thread::globally(function(){
            
$std = new stdClass;
        });
        
        
var_dump($std);
    }
}
$my = new My();
$my->start();
?>

以上例程会输出:

object(stdClass)#3 (0) {
}