0

Following is structure of processing data and printing results. Some contents will be printed out during process_records, so I want for all threads ensure part can be printed out at very end of program running together with order, like first thread's ensure part should be printed out first. How can I do that without moving print_report out of Thread.new do? Thanks

lock = Mutex.new()
thread_num.times do |i|
    threads << Thread.new do
             records = lock.synchronize{db_proxy.query(account_id)}

             result1 = process_records(records) 
             result2 = process_records2(records)
             result3 = process_records3(records)
             ensure
                 print_report(result1, result2, result3)
             end
        }        
    end
end
Yining Teng
  • 9
  • 1
  • 4

0 Answers0