From: Igor Pirnovar Date: 2012-10-12T10:00:37+09:00 Subject: Re: Threads not concurrent Hi, Ajay! Your process of updating server i.e. the following code: process=Process.new(obj) process.process_on() processed_obj=process.obj server.update_obj(processed_obj) is taking different times to complete in the two threads. Hopefully, you can fix this by trying to tweak the {{ sleep(6) }}. For example the following code (of course in your version) may fix your problem: #!/usr/bin/env ruby children=[] for i in 1..2 children[i-1]=Thread.new do stop_flag = false puts "A new thread created----------------------" #line alpha while !stop_flag sleep(i) puts "inside loop----------------------" sleep(i==2?6:1) # <<< This will fix your problem stop_flag = true next end puts "--A thread completed" end sleep 0.5 # <<< Try delaying creation of threads for short time end children.each { |t| t.join } Regards, igor -- Posted via http://www.ruby-forum.com/.