Thread::getCreatorId

(PECL pthreads >= 2.0.0)

Thread::getCreatorId識別

說明

public Thread::getCreatorId(): int

返回創(chuàng)建當前線程的線程ID。

參數(shù)

此函數(shù)沒有參數(shù)。

返回值

線程ID,數(shù)字格式

范例

示例 #1 返回創(chuàng)建線程的線程或進程ID

<?php
class My extends Thread {
    public function 
run() {
        
printf("%s created by Thread #%lu\n"__CLASS__$this->getCreatorId());
    }
}
$my = new My();
$my->start();
?>

以上例程會輸出:

My created by Thread #123456778899