Hi my code looks like:
================few lines of codes
childredn=[]
for i in 1…2
children[i-1]=Thread.new do
DRb.start_service
server_uri=ARGV.shift
server = DRbObject.new nil, server_uri
puts “A new thread created----------------------” #line alpha
while !server.get_stop_flag
sleep(i)
puts “inside loop----------------------”
begin
obj=server.get_object_s
if !(Obj===obj and obj!=nil)
sleep(6)
next
end
process=Process.new(obj)
process.process_on()
processed_obj=process.obj
server.update_obj(processed_obj)
rescue => e
$logger.log_it("Error in client, ", e.message)
end
end
puts “–A thread completed”
end
end
children.each do |t|
if t!=nil
t.join
end
end
================few lines of codes
#---------------
The sequence of print is like:
puts “A new thread created----------------------”
puts “A new thread created----------------------”
puts “inside loop----------------------”
–A thread completed
puts “inside loop----------------------”
–A thread completed
But I want:
puts “A new thread created----------------------”
puts “A new thread created----------------------”
puts “inside loop----------------------”
puts “inside loop----------------------”
–A thread completed
–A thread completed
For your information I have used ‘system’ to start this block of script
from another ruby script.
The blocked thread is blocked at #line alpha, i.e #line alpha is
executed, after that it stops (not killed but paused.)