grizzly http server should keep running

后端 未结 3 621
有刺的猬
有刺的猬 2020-12-29 10:49

Below is the code to start Grizzly Http Server. If I press any key the server stops. Is there any way to keep it alive.

Jetty has join() method, which will not exit

3条回答
  •  甜味超标
    2020-12-29 11:25

    Try something like:

        try {
            server.start();
            Thread.currentThread().join();
        } catch (Exception ioe) {
            System.err.println(ioe);
        } finally {
            try {
                server.stop();
            } catch (IOException ioe) {
                System.err.println(ioe);
            }
        }
    

提交回复
热议问题