title: How to use multi-threading in rails 3?
body: <p>I am sending mail to the users using actionmailer through postmark. This is my code in controller:</p>
  
  <pre><code>@users = User.where(some condition)
  @product = Product.find_by_name(some name).first
  for user in @users
    UserMailer.new_product_arrival(user, @product, home_url).deliver
  end
  </code></pre>
  
  <p>and this my user_mailer.rb</p>
  
  <pre><code>def new_product_arrival(user,product,home_url)
    @from         = Settings.mailer_from_address
    @recipients   = user.login
    @sent_on      = Time.now
    @user = user
    @product = product
    @content_type = "text/html"
    @home_url = home_url
  end
  </code></pre>
  
  <p>The problem is that if there are more than 10 users it takes a very long time because of the <code>for</code> loop. I need to know if we can handle this by using multi-threading or background job. I don't want to use background job, but can anyone tell me how to implement the above using multi-threading.</p>
  
  <p>I am using ruby 1.8.7 and rails 3.0.7</p>