资源加载中... loading...

getThread



```getThread()```函数返回通过参数指定threadId的```Thread```对象

```Thread```对象


getThread(threadId)

参数```threadId```为线程对象Id,通过指定参数获取对应的线程对象。

threadId
true
number

```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获取指定的线程对象。

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

如果期望获取的线程已经执行完毕、释放,此时无法通过threading.getThread(threadId)获取该线程的线程对象。

{@fun/Threads/threading/Thread Thread}, {@fun/Threads/threading/mainThread mainThread}, {@fun/Threads/threading/currentThread currentThread}, {@fun/Threads/threading/Lock Lock}, {@fun/Threads/threading/Condition Condition}, {@fun/Threads/threading/Event Event}, {@fun/Threads/threading/Dict Dict}, {@fun/Threads/threading/pending pending}, {@fun/Threads/threading/eventLoop eventLoop}

Thread mainThread