2024 年日本 PHP 研討會

Thread::isJoined

(PECL pthreads >= 2.0.0)

Thread::isJoined狀態偵測

說明

public Thread::isJoined(): 布林值

判斷參考的執行緒是否已加入

參數

此函式沒有參數。

回傳值

成功時回傳 true,失敗時回傳 false

範例

範例 #1 偵測參考執行緒的狀態

<?php
class My extends Thread {
public function
run() {
$this->synchronized(function($thread){
if (!
$thread->done)
$thread->wait();
},
$this);
}
}
$my = new My();
$my->start();
var_dump($my->isJoined());
$my->synchronized(function($thread){
$thread->done = true;
$thread->notify();
},
$my);
?>

以上範例將輸出:

bool(false)

新增註解

使用者貢獻的註解

此頁面沒有使用者貢獻的註解。
To Top