The mainThread()
function is used to obtain the thread object of the main thread, that is, the thread where the main()
function in the strategy is located.
The mainThread()
function returns the thread object of the main thread.
Thread
object
mainThread()
function main() {
Log("The threadId of the main thread:", threading.mainThread().id())
}
Get the Thread
object of the main thread and output the threadId
of the main thread.
function test() {
Log("Output the main thread ID in the test function:", threading.mainThread().id())
}
function main() {
var t1 = threading.Thread(test)
t1.join()
}
The thread object of the main thread can also be obtained in concurrent threads.
It supports backtesting system and live trading environment.
{@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