threading.getThread
Gets a thread object based on the specified thread ID.
getThread(threadId)Examples
Get the specified thread object by threadId.
javascript
function main() {
var t1 = threading.Thread(function () {
// Thread object has method: id(), used to get the thread's Id, you can check the documentation for the corresponding Thread object section
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()
}Returns
| Type | Description |
|
|
Arguments
| Name | Type | Required | Description |
threadId | number | Yes | The parameter |
See Also
Remarks
Supports backtesting system and live trading environment.
If the target thread has finished executing and been released, the thread object cannot be obtained through threading.getThread(threadId).