# File lib/core/container.rb, line 191
    def run
      @lock.synchronize do
        @running += 1        # Note: ensure clause below will decrement @running
        raise StoppedError if @stopped
      end
      while task = @work.pop
        run_one(task, Time.now)
      end
      @lock.synchronize { raise @panic if @panic }
    ensure
      @lock.synchronize do
        if (@running -= 1) > 0
          work_wake nil         # Signal the next thread
        else
          # This is the last thread, no need to do maybe_panic around this final handler call.
          @adapter.on_container_stop(self) if @adapter.respond_to? :on_container_stop
        end
      end
    end