def threaded_run!(files, change)
      return if files.empty?
      file_number = 0
      total_files = files.length
      mutex       = Mutex.new
      threads     = []
      5.times do |i|
        threads[i] = Thread.new {
          until files.empty?
            mutex.synchronize do
              file_number += 1
              Thread.current["file_number"] = file_number
            end
            file = files.pop rescue nil
            next unless file
            Rails.logger.info "[#{Thread.current["file_number"]}/#{total_files}] to #{change}..."
            
            case change
            when 'destroy'
            when 'create'
            when 'update'
            end
          end
        }
      end
      threads.each { |t| t.join }
    end
def threaded_run!(files, change)
      return if files.empty?
      file_number = 0
      total_files = files.length
      mutex       = Mutex.new
      threads     = []
      5.times do |i|
        threads[i] = Thread.new {
          until files.empty?
            mutex.synchronize do
              file_number += 1
              Thread.current["file_number"] = file_number
            end
            file = files.pop rescue nil
            next unless file
            Rails.logger.info "[#{Thread.current["file_number"]}/#{total_files}] to #{change}..."
            
            case change
            when 'destroy'
            when 'create'
            when 'update'
            end
          end
        }
      end
      threads.each { |t| t.join }
    end
todo improve speed