るりまサーチ

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

別のキーワード

  1. drb thread
  2. etc sc_thread_threads_max
  3. tracer get_thread_no
  4. etc sc_thread_prio_protect
  5. tracer display_thread_id?

検索結果

Thread::ConditionVariable#broadcast -> self (38272.0)

状態変数を待っているスレッドをすべて再開します。再開された スレッドは Thread::ConditionVariable#wait で指定した mutex のロックを試みます。

...スレッドは Thread::ConditionVariable#wait
で指定した mutex のロックを試みます。

@return 常に self を返します。

//emlist[例][ruby]{
mutex = Mutex.new
cv = ConditionVariable.new
flg = true

3.times {
Thread
.start {
mutex.synchronize {
puts "a1"
while (...
...flg)
cv.wait(mutex)
end
puts "a2"
}
}
}

Thread
.start {
mutex.synchronize {
flg = false
cv.broadcast
}
}

sleep 1

# => a1
# => a1
# => a1
# => a2
# => a2
# => a2
//}...