Built-in Functions
Structures
Built-in Variables and Constants
Conventions
Exchanges
ThreadDict.get
Retrieves the value of a key recorded in a dictionary object.
get(key)Examples
Use event objects to notify threads to read and modify data.
javascript
function main() {
var threadRead = threading.Event() // the thread has read the data
var mainChanged = threading.Event() // the main thread has changed the data
var dict = threading.Dict()
dict.set("data", 100)
var t1 = threading.Thread(function(dict, threadRead, mainChanged) {
Log(`thread1, dict.get("data"):`, dict.get("data"))
threadRead.set()
mainChanged.wait()
Log(`after main change data, thread1 dict.get("data"):`, dict.get("data"))
dict.set("data", 0)
}, dict, threadRead, mainChanged)
threadRead.wait()
dict.set("data", 99)
mainChanged.set()
t1.join()
Log(`main thread, dict.get("data"):`, dict.get("data"))
}Returns
| Type | Description |
string / number / bool / object / array / any | Value corresponding to the key specified by the |
Arguments
| Name | Type | Required | Description |
key | string | Yes | Key name to retrieve. |
See Also