def run(app)
      synchronize do
        @interruptable = []
        int_orig = trap "INT" do
          stop()
        end
        term_orig = trap "TERM" do
          stop()
        end
        begin
          @listener = create_listener(@options)
          @interruptable.extend Mutex_m
          if (@max_clients > 1)
            @master = Thread.current
            @workers = (0...@max_clients).collect do
              Thread.new do
                begin
                  process_client(app)
                rescue GracefulExit, SystemExit => e
                  # let it exit.
                rescue => e
                  $stderr.puts("Handler thread unexpectedly died with #{e}:", e.backtrace)
                end
              end
            end
            @workers.each do |worker|
              worker.join
            end
          else
            begin
              @master = Thread.current
              @workers = [Thread.current]
              process_client(app)
            rescue GracefulExit, SystemExit => e
              # let it exit
            rescue => e
              $stderr.puts("Handler thread unexpectedly died with #{e}:", e.backtrace)
            end
          end      
        ensure
          trap "INT", int_orig
          trap "TERM", term_orig
          @listener.close if (@listener && !@listener.closed?)
          @interruptable = @listener = @master = @workers = nil
        end
      end
    end
def run(app)
      synchronize do
        @interruptable = []
        int_orig = trap "INT" do
          stop()
        end
        term_orig = trap "TERM" do
          stop()
        end
        begin
          @listener = create_listener(@options)
          @interruptable.extend Mutex_m
          if (@max_clients > 1)
            @master = Thread.current
            @workers = (0...@max_clients).collect do
              Thread.new do
                begin
                  process_client(app)
                rescue GracefulExit, SystemExit => e
                  # let it exit.
                rescue => e
                  $stderr.puts("Handler thread unexpectedly died with #{e}:", e.backtrace)
                end
              end
            end
            @workers.each do |worker|
              worker.join
            end
          else
            begin
              @master = Thread.current
              @workers = [Thread.current]
              process_client(app)
            rescue GracefulExit, SystemExit => e
              # let it exit
            rescue => e
              $stderr.puts("Handler thread unexpectedly died with #{e}:", e.backtrace)
            end
          end      
        ensure
          trap "INT", int_orig
          trap "TERM", term_orig
          @listener.close if (@listener && !@listener.closed?)
          @interruptable = @listener = @master = @workers = nil
        end
      end
    end
Runs the application through the configured handler.
 Can only be run once at a time. If you try to run it more than
 once, the second run will block until the first finishes.