Built-in Functions
Structures
Built-in Variables and Constants
Conventions
Exchanges
threading.mainThread
Gets the thread object of the main thread, which is the thread where the main() function in the strategy is located.
mainThread()Examples
-
Get the
Threadobject of the main thread and output thethreadIdof the main thread.javascriptfunction main() { Log("Main thread ID:", threading.mainThread().id()) } -
The thread object of the main thread can also be obtained in concurrent threads.
javascriptfunction test() { Log("Main thread ID output in test function:", threading.mainThread().id()) } function main() { var t1 = threading.Thread(test) t1.join() }
Returns
| Type | Description |
| Thread object of the main thread. |
See Also
Remarks
Supported in backtesting system and live trading environment.