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

mainThread

mainThread()函数用于获取主线程的线程对象,即策略中main()函数所在的线程。

mainThread()函数返回主线程的线程对象。

Thread对象

mainThread()

function main() {
    Log("主线程的threadId:", threading.mainThread().id())
}

获取主线程的Thread对象,输出主线程的threadId

function test() {
    Log("test函数中输出主线程Id:", threading.mainThread().id())
}

function main() {
    var t1 = threading.Thread(test)
    t1.join()
}

在并发的线程中也可以获取主线程的线程对象。

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

{@fun/Threads/threading/getThread getThread}, {@fun/Threads/threading/Thread Thread}, {@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}

getThread currentThread