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

ThreadEvent

Event object, used for multi-threaded event notification and signal.

set

The set() function is used to notify events (set signals).

set()

Please refer to the threading.Event() section for examples.

If the signal has been set using set(), it cannot be set again. We need to clear the signal and set it again.

{@fun/Threads/ThreadEvent/clear clear}, {@fun/Threads/ThreadEvent/wait wait}, {@fun/Threads/ThreadEvent/isSet isSet}

clear

The clear() function is used to clear the signal.

clear()

Please refer to the threading.Event() section for examples.

{@fun/Threads/ThreadEvent/set set}, {@fun/Threads/ThreadEvent/wait wait}, {@fun/Threads/ThreadEvent/isSet isSet}

wait

The wait() function is used to set an event (signal) wait, and will block before the event (signal) is set; it supports setting a timeout parameter.

The wait() function returns whether the timeout has occurred. If so, it returns a true value.

bool

wait() wait(timeout)

The timeout parameter is used to set the waiting timeout in milliseconds.

timeout false number

function main() {
    var event = threading.Event()
    var t1 = threading.Thread(function(event) {
        var ret = event.wait(100)
        Log(`event.wait(100):`, ret)
        ret = event.wait()
        Log(`event.wait():`, ret)
    }, event)

    Sleep(1000)
    event.set()
    t1.join()
}

Test the return value of the wait() function.

{@fun/Threads/ThreadEvent/set set}, {@fun/Threads/ThreadEvent/clear clear}, {@fun/Threads/ThreadEvent/isSet isSet}

isSet

The isSet() function is used to determine whether an event (signal) has been set.

The isSet() function returns whether the event (signal) has been set; if the event (signal) has been set, it returns a true value.

bool

isSet()

Please refer to the threading.Event() section for examples.

{@fun/Threads/ThreadEvent/set set}, {@fun/Threads/ThreadEvent/clear clear}, {@fun/Threads/ThreadEvent/wait wait}

ThreadLock ThreadCondition