るりまサーチ

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

別のキーワード

  1. etc sc_xopen_enh_i18n
  2. pop n_mails
  3. openssl n=
  4. pop3 n_mails
  5. openssl n

ライブラリ

クラス

検索結果

Thread#value -> object (18174.0)

スレッド self が終了するまで待ち(Thread#join と同じ)、 そのスレッドのブロックが返した値を返します。スレッド実行中に例外が 発生した場合には、その例外を再発生させます。

...self が終了するまで待ち(Thread#join と同じ)、
そのスレッドのブロックが返した値を返します。スレッド実行中に例外が
発生した場合には、その例外を再発生させます。

スレッドが Thread#kill によって終了した場合は、返り...
...力する例です。

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}...

Thread#terminate -> self (3114.0)

スレッドの実行を終了させます。終了時に ensure 節が実行されます。

...時に ensure 節が実行されます。

ただし、スレッドは終了処理中(aborting)にはなりますが、
直ちに終了するとは限りません。すでに終了している場合は何もしません。このメソッドにより
終了したスレッドの Thread#value の返り...
...Kernel.#exit(0)
により終了します。

Kernel.#exit と違い例外 SystemExit を発生しません。

th1 = Thread.new do
begin
sleep 10
ensure
p "this will be displayed"
end
end

sleep 0.1
th1.kill

#=> "this will be displayed"

@see Kernel.#exit, Kernel...