るりまサーチ

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

別のキーワード

  1. drb thread
  2. thread exit
  3. thread join
  4. thread kill
  5. etc sc_thread_cputime

ライブラリ

モジュール

キーワード

検索結果

<< < 1 2 >>

Thread::ConditionVariable#signal -> self (3051.0)

状態変数を待っているスレッドを1つ再開します。再開された スレッドは 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 {
pu...
...ts "a1"
while (flg)
cv.wait(mutex)
end
puts "a2"
}
}
}

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

sleep 1

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

Thread::Queue#close -> self (3043.0)

キューを close します。close 済みのキューを再度 open することはできません。

...以下のように動作します。

* Thread::Queue#closed? は true を返します
* Thread::Queue#close は無視されます
* Thread::Queue#enq/push/<< は ClosedQueueError を発生します
* Thread::Queue#empty? が false を返す場合は Thread::Queue#deq/pop/shift は通常通り...
...オブジェクトを返します

また、ClosedQueueError は StopIteration を継承しているため、
close する事でループから脱出する事もできます。

例:

q = Queue.new
Thread
.new{
while e = q.deq # wait for nil to break loop
# ...
end
}
q.close...
<< < 1 2 >>