24件ヒット
[1-24件を表示]
(0.117秒)
別のキーワード
クラス
- Thread (12)
-
Thread
:: Queue (12)
検索結果
-
Thread
:: Queue # push(value) -> () (18305.0) -
キューの値を追加します。待っているスレッドがいれば実行を再開 させます。返り値は不定です。
キューの値を追加します。待っているスレッドがいれば実行を再開
させます。返り値は不定です。 -
Thread
# value -> object (18144.0) -
スレッド self が終了するまで待ち(Thread#join と同じ)、 そのスレッドのブロックが返した値を返します。スレッド実行中に例外が 発生した場合には、その例外を再発生させます。
...を出力する例です。
threads = []
threads.push(Thread.new { n = rand(5); sleep n; n })
threads.push(Thread.new { n = rand(5); sleep n; n })
threads.push(Thread.new { n = rand(5); sleep n; n })
threads.each {|t| p t.value}
最後の行で、待ち合わせを行っている......ことがわかりにくいと思うなら以下
のように書くこともできます。
threads.each {|t| p t.join.value}...