Thread.getData
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
| Type | Description |
string / number / bool / object / array / any | Key value corresponding to the |
Arguments
| Name | Type | Required | Description |
key | string | Yes | Key name of the stored key-value pair. |
See Also