Does Threading work properly?

Hi

When I do this:

thr3 = Thread.new() do
loop do
puts "thread"
end
end

The loop only lasts for about 5 seconds - printing out ‘thread’ about
100 times

what I want is an infinite loop - like this, which works (except I want
my infinite loop to be contained within a thread)

loop do
puts "works"
end

Please help

Thanks
Kingsley

To answer the question in the subject: yes, threading does work properly :slight_smile:

When the main thread of your program reaches the end, all other threads are
killed too.

Add the following line at the end:

thr3.join

(which means “wait for thr3 to finish”, which of course it never does).

Regards,

Brian.

···

On Tue, Jul 01, 2003 at 01:12:50AM +0900, kingsley@icecode.org wrote:

Hi

When I do this:

thr3 = Thread.new() do
loop do
puts "thread"
end
end

The loop only lasts for about 5 seconds - printing out 'thread' about
100 times