るりまサーチ

最速Rubyリファレンスマニュアル検索!
166件ヒット [1-100件を表示] (0.117秒)
トップページ > クエリ:-[x] > クエリ:u[x] > クラス:Thread[x]

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

ライブラリ

キーワード

検索結果

<< 1 2 > >>

Thread#group -> ThreadGroup (6301.0)

スレッドが属している ThreadGroup オブジェクトを返します。

...スレッドが属している ThreadGroup オブジェクトを返します。

p Thread.current.group == ThreadGroup::Default
# => true...

Thread::MUTEX_FOR_THREAD_EXCLUSIVE -> Mutex (6301.0)

Thread.exclusive用のMutexオブジェクトです。 (private constant です。)

...
Thread
.exclusive用のMutexオブジェクトです。...
...
Thread
.exclusive用のMutexオブジェクトです。
(private constant です。)...

Thread#set_trace_func(pr) -> Proc | nil (6243.0)

スレッドにトレース用ハンドラを設定します。

...返します。

//emlist[例][ruby]{
th = Thread.new do
class Trace
end
2.to_s
Thread
.current.set_trace_func nil
3.to_s
end
th.set_trace_func lambda {|*arg| p arg }
th.join

# => ["line", "example.rb", 2, nil, #<Binding:0x00007fc8de87cb08>, nil]
# => ["c-call", "example.rb", 2, :inherited...
..., #<Binding:0x00007fc8de886770>, Class]
# => ["c-return", "example.rb", 2, :inherited, #<Binding:0x00007fc8de8844e8>, Class]
# => ["class", "example.rb", 2, nil, #<Binding:0x00007fc8de88e830>, nil]
# => ["end", "example.rb", 3, nil, #<Binding:0x00007fc8de88d6b0>, nil]
# => ["line", "example.rb", 4,...
...440>, nil]
# => ["c-call", "example.rb", 4, :to_s, #<Binding:0x00007fc8de896f30>, Integer]
# => ["c-return", "example.rb", 4, :to_s, #<Binding:0x00007fc8de894a50>, Integer]
# => ["line", "example.rb", 5, nil, #<Binding:0x00007fc8de967b08>, nil]
# => ["c-call", "example.rb", 5, :current, #<Binding:0x...

Thread#add_trace_func(pr) -> Proc (6225.0)

スレッドにトレース用ハンドラを追加します。

...mlist[例][ruby]{
th = Thread.new do
class Trace
end
43.to_s
end
th.add_trace_func lambda {|*arg| p arg }
th.join

# => ["line", "example.rb", 4, nil, #<Binding:0x00007f98e107d0d8>, nil]
# => ["c-call", "example.rb", 4, :inherited, #<Binding:0x00007f98e1087448>, Class]
# => ["c-return", "examp...
...e0>, nil]
# => ["line", "example.rb", 6, nil, #<Binding:0x00007f98e108d4b0>, nil]
# => ["c-call", "example.rb", 6, :to_s, #<Binding:0x00007f98e1097aa0>, Integer]
# => ["c-return", "example.rb", 6, :to_s, #<Binding:0x00007f98e1095cc8>, Integer]
//}

@see Thread#set_trace_func Kernel.#set_trace_func...

Thread.DEBUG -> Integer (6207.0)

スレッドのデバッグレベルを返します。

...れ以外の場合は、スレッドのデバッグログを標準出力に出力します。
初期値は 0 です。
使用するためには、THREAD_DEBUG を -1 にして Ruby をコンパイルする必要が
あります。

//emlist[例][ruby]{
Thread
.DEBUG # => 0
//}

@see Thread.DEBUG=...

絞り込み条件を変える

Thread#pending_interrupt?(error = nil) -> bool (6201.0)

self の非同期例外のキューが空かどうかを返します。

...self の非同期例外のキューが空かどうかを返します。

@param error 対象の例外クラスを指定します。


@see Thread.pending_interrupt?...

Thread#run -> self (6201.0)

停止状態(stop)のスレッドを再開させます。 Thread#wakeup と異なりすぐにスレッドの切り替え を行います。

...す。
Thread
#wakeup と異なりすぐにスレッドの切り替え
を行います。

@raise ThreadError 死んでいるスレッドに対して実行すると発生します。

//emlist[例][ruby]{
a = Thread.new { puts "a"; Thread.stop; puts "c" }
sleep 0.1 while a.status!='sleep'
puts "Got h...
...ere"
a.run
a.join
# => a
# => Got here
# => c
//}

@see Thread#wakeup, Thread.stop...

Thread#status -> String | false | nil (6201.0)

生きているスレッドの状態を文字列 "run"、"sleep", "aborting" のいず れかで返します。正常終了したスレッドに対して false、例外によ り終了したスレッドに対して nil を返します。

...字列 "run"、"sleep", "aborting" のいず
れかで返します。正常終了したスレッドに対して false、例外によ
り終了したスレッドに対して nil を返します。

Thread
#alive? が真を返すなら、このメソッドも真です。

例:
a = Thread.new { raise(...
..."die now") }
b = Thread.new { Thread.stop }
c = Thread.new { Thread.exit }
d = Thread.new { sleep }
d.kill #=> #<Thread:0x401b3678 aborting>
a.status #=> nil
b.status #=> "sleep"
c.status #=> false
d.status...
...#=> "aborting"
Thread.current.status #=> "run"

@see Thread#alive?, Thread#stop?...

Thread#value -> object (6201.0)

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

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

スレッドが Thread#kill によって終了した場合は、...
...を待ち結果を出力する例です。

thread
s = []
thread
s.push(Thread.new { n = rand(5); sleep n; n })
thread
s.push(Thread.new { n = rand(5); sleep n; n })
thread
s.push(Thread.new { n = rand(5); sleep n; n })

thread
s.each {|t| p t.value}

最後の行で、待ち合わせを...
...行っていることがわかりにくいと思うなら以下
のように書くこともできます。

thread
s.each {|t| p t.join.value}...

Thread#wakeup -> self (6201.0)

停止状態(stop)のスレッドを実行可能状態(run)にします。

...を実行可能状態(run)にします。

@raise ThreadError 死んでいるスレッドに対して実行すると発生します。

//emlist[例][ruby]{
c = Thread.new { Thread.stop; puts "hey!" }
sleep 0.1 while c.status!='sleep'
c.wakeup
c.join
# => "hey!"
//}

@see Thread#run, Thread.stop...

絞り込み条件を変える

<< 1 2 > >>