I would suggest that the problem is that you loop in Main's constructor, so that Main.new operation never ends. I suspect that new is implemented inside ruby interpreter as C code, and it is a well a known fact that entering C code takes over the whole interpreter. That's why it is so important to remember when writing C extensions. Here, however, you simply got in the way of the interpreter putting all your processing in the constructor. It is just a guess. I did not check it in the code, so I may be totally wrong. Gennady. On Aug 11, 2004, at 7:35 AM, Andre' wrote: > Strangely, I'm having the problem that one thread is taking over the > whole process. > > Imagine this main file: > > Thread.new { > class Main > def initialize > while true > print 1 > end > end > end > m = Main.new > } > Thread.new { > require 'p.rb' > m = Main.new > } > while true; end > > It has two threads: one is printing 1 all the time in the screen. I > have a second - external - that is exactly like the first, but it > prints 2. The 'p.rb' is this one: > > class Main > def initialize > while true > print 2 > end > end > end > > It acts as expected. (11112222221111111222222) > > But if I add the line "m = Main.new" at the end of 'p.rb', the thread > seems to take over! (22222222222222222222222222222222222) > > Since this 'p.rb' is some external file the users will input, I can't > tell what it'll be on it, so I can't avoid that a malicious code takes > over my program! Or can I? > > -- > (c) Andre' - All rights reseved - 2004 > > Sincerely, Gennady Bystritsky