From: Marcin Tyman Date: 2007-06-30T04:42:32+09:00 Subject: Re: Threads issue. Lionel Bouton wrote: > Marcin Tyman wrote: >> end >> while i<10 >> i+=1 >> puts "Main thread: #{Thread.current}" >> end >> >> puts "myThread is not alive" if !myThread.alive? >> Thread.pass #####################################here is my >> issue!!!! >> myThread.run >> > > Only an educated guess : > myThread may not have stopped yet here. Strictly speaking, even > Thread.pass can not guarantee it because the scheduler could decide to > pass the control back to the "primary" thread before i == 40 in my(). > If you get a deadlock it probably means that Thread#run cannot be called > on an already running Thread (which isn't really surprising but if true > should be mentionned in its documentation). > > If it works with either Thread.pass or Thread.stop in the Thread.new > block uncommented my guess could very well be the actual source of your > problem. > > Lionel Lionel, It looks like the issue is in Thread#run which doesn't guarantee starting myThread before Thread#join. If i.e. myThread.pass is commented out and any time consuming loop is included before myThread.run everything works fine (without Thread#pass). -- Posted via http://www.ruby-forum.com/.