[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

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

Ming en Chia

4/11/2007 7:54:00 PM

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....))

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....))
end

--
Posted via http://www.ruby-....

1 Answer

Brian Candler

4/11/2007 8:12:00 PM

0

On Thu, Apr 12, 2007 at 04:54:05AM +0900, Ming en Chia wrote:
> 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....))
>
> 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....))
> 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.