资源加载中... loading...

get

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}

ThreadCondition set