Project

General

Profile

Actions

Bug #289

closed

sleep and Thread#run

Added by Anonymous almost 16 years ago. Updated about 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
Backport:
[ruby-dev:35542]

Description

=begin
1.9 では sleep で寝ているスレッドを Thread#run で起こせない
ようです。

% ./ruby -ve '
t = Thread.new {
t1 = Time.now
sleep 5
t2 = Time.now
p t2 - t1
}
sleep 1
t.run
t.join
'
ruby 1.9.0 (2008-07-16 revision 18083) [i686-linux]
5.139447392

sleep を Thread#run で起こせるっぽいことは rdoc に書いてありま
す。

  • Suspends the current thread for duration seconds (which may be any number,
  • including a +Float+ with fractional seconds). Returns the actual number of
  • seconds slept (rounded), which may be less than that asked for if another
  • thread calls Thread#run. Zero arguments causes +sleep+ to sleep
  • forever.

また、1.8 では起こせます。

% ruby-1.8 -ve '
t = Thread.new {
t1 = Time.now
sleep 5
t2 = Time.now
p t2 - t1
}
sleep 1
t.run
t.join
'
ruby 1.8.7 (2008-07-10 revision 17572) [i686-linux]
1.002687

[田中 哲][たなか あきら][Tanaka Akira]
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0