code: public static Socket accept(ServerSocket serverSocket, final boolean runInANewThread,
                                  @ClosureParams(value=SimpleType.class, options="java.net.Socket") final Closure closure) throws IOException {
          final Socket socket = serverSocket.accept();
          if (runInANewThread) {
              new Thread(new Runnable() {
                  public void run() {
                      invokeClosureWithSocket(socket, closure);
                  }
              }).start();
          } else {
              invokeClosureWithSocket(socket, closure);
          }
          return socket;
      }
docs: Accepts a connection and passes the resulting Socket to the closure
  which runs in a new Thread or the calling thread, as needed.
  
  @param serverSocket    a ServerSocket
  @param runInANewThread This flag should be true, if the closure should be invoked in a new thread, else false.
  @param closure         a Closure
  @return a Socket
  @throws IOException if an IOException occurs.
  @see java.net.ServerSocket#accept()
  @since 1.7.6