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
threading.Thread
threading.getThread
threading.mainThread
threading.currentThread
threading.Lock
threading.Condition
threading.Event
threading.Dict
threading.Serve
threading.pending
Thread
ThreadLock
ThreadEvent
ThreadCondition
ThreadDict
Server
TA
Talib
OS
Structures
Built-in Variables and Constants
Conventions
Exchanges

Gets the number of concurrent threads currently running in the strategy program.

pending()

Examples

Create two concurrently running threads and call the pending() function at different time points.

javascript
function threadFun1() { Log("threadFun1") Sleep(3000) } function threadFun2() { for (var i = 0; i < 3; i++) { LogStatus(_D(), "print from threadFun2") Sleep(3000) } } function main() { Log(`begin -- threading.pending():`, threading.pending()) var t1 = threading.Thread(threadFun1) var t2 = threading.Thread(threadFun2) Log(`after threading.Thread -- threading.pending():`, threading.pending()) t1.join() t2.join() Log(`after thread.join -- threading.pending():`, threading.pending()) }

Returns

TypeDescription

number

Number of concurrent threads currently running in the strategy program.

See Also

Remarks

When the strategy's main() function starts running, directly calling pending() will return 1, because the main thread where main() function is located is also counted as a running thread.

Supports both backtesting system and live trading environment.