Problem calling Net::HTTP.get_response in Thread.new

M

Ming en Chia

i had a strange problem of unable to call Net::HTTP.get_response in
thread
example this work well

Net::HTTP.get_response(URI.parse("http://www.google.com/"))

however when i called inside a thread it does not work it does not work,
i was wondering why.

Thread.new do
Net::HTTP.get_response(URI.parse("http://www.google.com/"))
end
 
B

Brian Candler

i had a strange problem of unable to call Net::HTTP.get_response in
thread
example this work well

Net::HTTP.get_response(URI.parse("http://www.google.com/"))

however when i called inside a thread it does not work it does not work,
i was wondering why.

Thread.new do
Net::HTTP.get_response(URI.parse("http://www.google.com/"))
end

Is that your entire program? If so you will need

t = Thread.new do
# whatever
end
t.join

Otherwise the main program will exit immediately, and terminate all other
threads.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top