資源の読み込みに... 荷物...

加入する



[```ThreadRet```对象](https://www.fmz.com/syntax-guide/struct/otherstruct/Thread.join-return)包含执行结果的相关数据,包含的属性如下:

- id: 线程Id。
- terminated: 线程是否被强制结束。
- elapsed: 线程的运行时间(纳秒)。
- ret: 线程函数的返回值。

```ThreadRet```对象


join()
join(timeout)

```timeout```参数用于设置等待线程结束的超时时间,单位为毫秒。```timeout```参数设置为0或者不设置```timeout```参数时```join()```函数会阻塞,等待到线程执行结束。```timeout```参数设置为-1时,```join()```函数会立即返回。

timeout
false
number

```javascript
function main() {
    var t1 = threading.Thread(function() {
        Log("Hello thread1")
        Sleep(5000)
    })

    var ret = t1.join(1000)
    Log("ret:", ret)   // ret: undefined

    ret = t1.join()
    Log("ret:", ret)   // ret: {"id":1,"terminated":false,"elapsed":5003252000}
}

テストjoin()函数が終了すると,出力値が返されます.

join()この関数には,undefined

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

投稿メッセージ 終了する