"Michael Neumann" <neumann / s-direktnet.de> writes:

> It seems to me that I cannot read from files inside a thread. If I do so,
> the thread terminates.

Does the following code work for you (run it with the number of
threads to start as an argument)

     threads = []
     1.upto(ARGV[0].to_i) do |num|
       puts "In thread #{num}"
       thread = Thread.start do
         myNumber = num
         IO.foreach("/etc/fstab") do |line|
           puts "#{myNumber}: #{line}"
           Thread.pass
         end
       end
       threads << thread
       puts "Leaving thread #{num}"
     end

     threads.each { |t| t.join }

If so, then you may just have a simple bug in your code. Try setting

    Thread.abort_on_exception = true

and running your code.


Regards


Dave