threading.getThread
根据指定的线程ID获取线程对象。
getThread(threadId)示例
通过threadId获取指定的线程对象。
javascript
function main() {
var t1 = threading.Thread(function () {
// Thread 对象有方法:id(),用于获取线程的Id,可以查看文档对应Thread对象的章节
var id = threading.currentThread().id()
var thread1 = threading.getThread(id)
Log("id:", id, ", thread1.id():", thread1.id())
Log(`id == thread1.id():`, id == thread1.id())
})
t1.join()
}返回值
| 类型 | 描述 |
| 由参数threadId指定的 |
参数
| 名称 | 类型 | 必填 | 描述 |
threadId | number | 是 | 线程对象ID,通过指定该参数获取对应的线程对象。 |
参考
备注
支持回测系统、实盘环境。
如果目标线程已经执行完毕并被释放,则无法通过threading.getThread(threadId)获取该线程的线程对象。