如果线程尚未启动,则 Thread::getThreadId() 返回 0。
(PECL pthreads >= 2.0.0)
Thread::getThreadId — 标识
此函数没有参数。
数字标识
示例 #1 返回引用的线程的标识
<?php
class My extends Thread {
public function run() {
printf("%s is Thread #%lu\n", __CLASS__, $this->getThreadId());
}
}
$my = new My();
$my->start();
?>
以上示例将输出
My is Thread #123456778899