Thread problem

hello,

on the following source i only see once
the msg 'thread 0' and then following endless
'main 1'
'main 2'
....

why does my thread blocks?

mark

require 'thread'

th = Thread.new do
    tcnt=0
    while 1 do
       print "thread " + tcnt.to_s + "\n"
       cnt = cnt+1;
       Sleep 0.5
       #stdout.flush
    end
end

while 1 do
  cnt=0
  print "main " + cnt.to_s + "\n"
  sleep 1
end

···

--
working with ruby 1.8.1 on winnt

Well, add the line

require 'thread'

   Thread.abort_on_exception = true

th = Thread.new do
    tcnt=0
    while 1 do
       print "thread " + tcnt.to_s + "\n"
       cnt = cnt+1;
       Sleep 0.5
       #stdout.flush
    end
end

and ruby will give you the error message

Guy Decoux

ts wrote:

"m" == mark shennce <no_possible_yet@do_not.try> writes:

Well, add the line

> require 'thread'

   Thread.abort_on_exception = true

it works.

thank you.