From: Marcin Tyman Date: 2007-06-30T03:27:49+09:00 Subject: Threads issue. Hi guys, Here is my program: ------------------------------------------------------------------------------ def my() i=0 while i<100 i+=1 puts "Into my: #{Thread.current}" Thread.stop if i == 40 end end myThread = Thread.new { puts "Into thread: #{Thread.current}" #Thread.stop my() } i=0 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 myThread.join() --------------------------------------------------------------------------- I cannot understand why this program cannot run without Thread.pass line. Without the line following message appeard: deadlock 0x283fef8: sleep:- - c:/Documents and Settings/Marcin/Moje dokumenty/P roximetry/Ruby/Threads2/threads2.rb:7 deadlock 0x284c748: sleep:J(0x283fef8) (main) - c:/Documents and Settings/Marcin /Moje dokumenty/Proximetry/Ruby/Threads2/threads2.rb:27 c:/Documents and Settings/Marcin/Moje dokumenty/Proximetry/Ruby/Threads2/threads 2.rb:27:in `join': Thread(0x284c748): deadlock (fatal) from c:/Documents and Settings/Marcin/Moje dokumenty/Proximetry/Ruby/Thr eads2/threads2.rb:27 I have lack of knowledge in programming threads but I supposed that myThread.run should starts stopped thread before myThread.join. Did I forget about something? I will be appreciated for any help Thanks in advance. -- Posted via http://www.ruby-forum.com/.