るりまサーチ

最速Rubyリファレンスマニュアル検索!
12件ヒット [1-12件を表示] (0.111秒)

別のキーワード

  1. etc sc_threads
  2. etc sc_thread_threads_max
  3. etc cs_posix_v7_threads_cflags
  4. etc cs_posix_v7_threads_ldflags
  5. etc sc_xopen_realtime_threads

ライブラリ

クラス

検索結果

Thread#value -> object (18150.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}...