Dictionary object, used for data sharing.
The get()
function is used to get the key value recorded in the dictionary object.
The get()
function returns the value of the key specified by the key
parameter.
string, number, bool, object, array, null value and other types supported by the system
get(key)
The key
parameter is used to specify the key name corresponding to the key to be obtained.
key true string
function main() {
var event = threading.Event()
var dict = threading.Dict()
dict.set("data", 100)
var t1 = threading.Thread(function(dict, event) {
Log(`thread1, dict.get("data"):`, dict.get("data"))
event.set()
event.clear()
event.wait()
Log(`after main change data, thread1 dict.get("data"):`, dict.get("data"))
dict.set("data", 0)
}, dict, event)
event.wait()
dict.set("data", 99)
event.set()
event.clear()
t1.join()
Log(`main thread, dict.get("data"):`, dict.get("data"))
}
Use event objects to notify threads to read and modify data.
{@fun/Threads/ThreadDict/set set}
The set()
function is used to set a key-value pair.
set(key, value)
The parameter key
is used to set the key name to be modified.
key
true
string
The parameter value
is used to set the key value to be modified.
value true string, number, bool, object, array, null value and other types supported by the system
Please refer to the ThreadDict.get()
section for examples.
{@fun/Threads/ThreadDict/get get}
ThreadCondition Web3