# Problem calling Net::HTTP.get\_response in Thread.new

**URL:** <https://www.ruby-forum.com/t/problem-calling-net-http-get-response-in-thread-new/91722>\
**Category:** Ruby\
**Created:** [April 11, 2007, 9:54pm UTC](https://www.ruby-forum.com/t/problem-calling-net-http-get-response-in-thread-new/91722 "2007-04-11T21:54:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ming\_en\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/57b2e6/32.png) [@Ming\_en\_C](https://www.ruby-forum.com/u/Ming_en_C)\
**Post date:** [April 11, 2007, 9:54pm UTC](https://www.ruby-forum.com/t/problem-calling-net-http-get-response-in-thread-new/91722/1 "2007-04-11T21:54:02Z")

</div>

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/](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/](http://www.google.com/)”))  
end

---

<div class="post-metadata">

**Author:** ![Ming\_en\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/57b2e6/32.png) [@Ming\_en\_C](https://www.ruby-forum.com/u/Ming_en_C)\
**Post date:** [April 11, 2007, 10:12pm UTC](https://www.ruby-forum.com/t/problem-calling-net-http-get-response-in-thread-new/91722/2 "2007-04-11T22:12:43Z")

</div>

On Thu, Apr 12, 2007 at 04:54:05AM +0900, Ming en Chia wrote:

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

---

<div class="post-metadata">

**Author:** ![Ming\_en\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/57b2e6/32.png) [@Ming\_en\_C](https://www.ruby-forum.com/u/Ming_en_C)\
**Post date:** [April 11, 2007, 10:43pm UTC](https://www.ruby-forum.com/t/problem-calling-net-http-get-response-in-thread-new/91722/3 "2007-04-11T22:43:23Z")

</div>

thank you, it works now
