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

Accesses variables recorded in the thread environment. The data is kept with the Thread object; after the thread has ended (join() or terminate()), it can still be read through a Thread object you still hold.

getData(key)

Examples

Record a value with the key name count in the concurrent thread environment, then read the key value of count in the main thread.

javascript
function main() { var t1 = threading.Thread(function() { for (var i = 0; i < 5; i++) { threading.currentThread().setData("count", i) Log(`setData("count"):`, i) Sleep(1000) } }) for (var i = 0; i < 5; i++) { var count = threading.getThread(t1.id()).getData("count") Log(`getData("count"):`, count) Sleep(1000) } t1.join() }

Returns

TypeDescription

string / number / bool / object / array / any

Key value corresponding to the key parameter in the key-value pairs stored in the current thread environment.

Arguments

NameTypeRequiredDescription

key

string

Yes

Key name of the stored key-value pair.

See Also