From: Venkat Bagam Date: 2008-02-27T17:16:12+09:00 Subject: Multithreading problem Hi All, I am pretty much a starter in multi-threading. In one of my application, I needed to run three threads along each other. Here is my code require 'rubygems' require 'mechanize' require 'fileutils' require 'timeout' agent = WWW::Mechanize.new start_time = Time.now threads = [] threads << Thread.new do puts "running thread1" start = 0 count = 10 finish = 30 while start < finish page_links = Array.new parent_url = "http://www.rknowsys.com" page = agent.get(parent_url) page = nil start += count end puts "thread1 completed" if start == finish end threads << Thread.new do puts "running thread2" start = 30 count = 10 finish = 60 while start < finish page_links = Array.new parent_url = "http://www.rknowsys.com" page = agent.get(parent_url) page = nil start += count raise "stopped bcaz start > 40" if start > 40 end puts "thread2 completed" if start == finish end threads.each do |thread| begin thread.join rescue RuntimeError => e puts e.message end end end_time = Time.now interval = end_time - start_time puts interval the above code prints the error message, at the time of each thread join and stops. But, How do I deal with such a scenario that the thread2 continues to run again setting its local variable start = 30 ? Any help appreciated. regards, Venkat Bagam -- Posted via http://www.ruby-forum.com/.