works:
      while threads.size > 50
        sleep 0.01
        deleted = []
        threads.delete_if { |thread| deleted << thread  if not thread.alive? }
        deleted.clear
      end

does not work:
      while threads.size > 50
        sleep 0.01
        threads.delete_if { |thread| if not thread.alive? }
      end