From: "Morris, Chris" Date: 2002-05-30T22:04:41+09:00 Subject: Thread id? The following is the pickaxe thread example that outputs the id value of each thread: require 'net/http' pages = %w( www.rubycentral.com www.awl.com www.pragmaticprogrammer.com ) threads = [] for page in pages threads << Thread.new(page) { |myPage| h = Net::HTTP.new(myPage, 80) puts "Fetching: #{myPage}" resp, data = h.get('/', nil ) puts "Got #{myPage}: #{resp.message} #{id.to_s}" } end threads.each { |aThread| aThread.join } Why does each thread output the same id value? S:\SF-scrapware\scrapware\ruby\cl\index\src>thread Fetching: www.rubycentral.com Fetching: www.awl.com Fetching: www.pragmaticprogrammer.com Got www.rubycentral.com: OK 22268684 Got www.pragmaticprogrammer.com: OK 22268684 Got www.awl.com: OK 22268684 S:\SF-scrapware\scrapware\ruby\cl\index\src>ruby -e 'puts RUBY_VERSION' 1.6.6 According to ri.rb: "The same number will be returned on all calls to id for a given object, and no two active objects will share an id." Isn't each Thread instance a separate object? Chris Morris chris.morris@snelling.com