2010/7/23 James Tucker <jftucker / gmail.com>:
>
> On 23 Jul 2010, at 05:55, Heesob Park wrote:
>
>> Bug #3606: Thread.stop and puts fail to work as documented.
>> http://redmine.ruby-lang.org/issues/show/3606
>>
>> Author: Heesob Park
>> Status: Open, Priority: Normal
>> Category: core, Target version: 1.9.x
>> ruby -v: ruby 1.9.3dev (2010-07-22 trunk 28707) [i686-linux]
>>
>> I have tested following three codes which are the sample code in RDoc Documentation.
>
> I see your point regarding this being code from the documentation. Examples as given in the documentation cannot work reliably with a preemptive scheduler and should be removed.
>
> I would also say that use of Thread.stop and Thread.pass for any kind of "synchrony" should be very strongly discouraged, we have locking primitives.
>
Thanks for your explanation.

I think that the sample code should be modified like this.

t1.rb
====================================================
a = Thread.new { puts "a"; Thread.stop; puts "c" }
sleep 0.1 while a.status!='sleep'
Thread.pass
puts "Got here"
a.run
a.join
sleep 1
====================================================

t2.rb
====================================================
a = Thread.new { print "a"; Thread.stop; print "c" }
sleep 0.1 while a.status!='sleep'
Thread.pass
print "b"
a.run
a.join
sleep 1
====================================================

t3.rb
====================================================
c = Thread.new { Thread.stop; puts "hey!" }
sleep 0.1 while c.status!='sleep'
c.wakeup
sleep 1
====================================================

Regards,
Park Heesob