Type/to search
Built-in Functions
Global
Log
Market
Trade
Account
Futures
Exchange
IO
Network
Storage
Threads
exchange.Go
EventLoop
ctx.subscribe
ctx.poll
ctx.order
ctx.cancel
ctx.submit
Subscription
threading
Thread
Thread.peekMessage
Thread.postMessage
Thread.join
Thread.terminate
Thread.getData
Thread.setData
Thread.id
Thread.name
Thread.eventLoop
ThreadLock
ThreadEvent
ThreadCondition
ThreadDict
Server
TA
Talib
OS
Structures
Built-in Variables and Constants
Conventions
Exchanges

Waits for a thread to exit and reclaims its system resources.

join()
join(timeout)

Examples

Test join() function timeout and output the return value.

javascript
function main() { var t1 = threading.Thread(function() { Log("Hello thread1") Sleep(5000) }) var ret = t1.join(1000) Log("ret:", ret) // Output: ret: undefined ret = t1.join() Log("ret:", ret) // Output: ret: {"id":1,"terminated":false,"elapsed":5003252000,"error":null} }

Returns

TypeDescription

ThreadRet object

A ThreadRet object: the thread ID (id), whether it was terminated (terminated), the running time (elapsed, nanoseconds), the error (error, null without an exception) and the return value of the thread function (ret).

Arguments

NameTypeRequiredDescription

timeout

number

No

Timeout for waiting for the thread to end, in milliseconds. When the timeout parameter is set to 0 or the timeout parameter is not set, the join() function will block until the thread finishes execution. When the timeout parameter is set to -1, the join() function will return immediately.

See Also

Remarks

When the join() function times out, it returns undefined.