输入/搜索内容
内置函数
Global
Log
Market
Trade
Account
Futures
Exchange
IO
Network
Storage
Threads
exchange.Go
EventLoop
ctx.subscribe
ctx.poll
ctx.order
ctx.cancel
ctx.submit
Subscription
threading
threading.Thread
threading.getThread
threading.mainThread
threading.currentThread
threading.Lock
threading.Condition
threading.Event
threading.Dict
threading.Serve
threading.pending
Thread
ThreadLock
ThreadEvent
ThreadCondition
ThreadDict
Server
TA
Talib
OS
结构体
内置变量与常量
通用约定
交易所

根据指定的线程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() }

返回值

类型描述

Thread对象

由参数threadId指定的Thread对象

参数

名称类型必填描述

threadId

number

是

线程对象ID,通过指定该参数获取对应的线程对象。

参考

备注

支持回测系统、实盘环境。

如果目标线程已经执行完毕并被释放,则无法通过threading.getThread(threadId)获取该线程的线程对象。