The resource loading... loading...

terminate

The terminate() function is used to forcibly terminate a thread and release the hardware resources used by the created thread.

terminate()

function main() {
    var t1 = threading.Thread(function() {
        for (var i = 0; i < 10; i++) {
            Log("thread1 i:", i)
            Sleep(1000)
        }
    })

    Sleep(3000)
    t1.terminate()
    Log("after t1.terminate()")

    while (true) {
        LogStatus(_D())
        Sleep(1000)
    }
}

Terminate the execution of a thread forcefully. After forcibly terminating a thread, there will be no output from this thread in the log.

For threads that are forcibly terminated by the terminate() function, we can no longer use the join() function to wait for them to terminate.

{@fun/Threads/Thread/peekMessage peekMessage}, {@fun/Threads/Thread/postMessage postMessage}, {@fun/Threads/Thread/join join}, {@fun/Threads/Thread/getData getData}, {@fun/Threads/Thread/setData setData}, {@fun/Threads/Thread/id id}, {@fun/Threads/Thread/name name}, {@fun/Threads/Thread/eventLoop eventLoop}

join getData