# CREDIT Greg

require 'thread'
require 'facets/core/enumerable/map_send'

module Enumerable

  def thread_map
    map{|e| Thread.new(e){|t| yield t}}.map_send(:value)
  end

  def thread_map_send( meth, *args )
    if block_given?
      map{|e| Thread.new(e){|t| yield t.send(meth, *args)}}.map_send(:value)
    else
      map{|e| Thread.new(e){|t| t.send(meth, *args)}}.map_send(:value)
    end
  end 

end

