我把this code:如何在Java中永遠運行程序? System.in.read()是唯一的方法嗎?
28 public static void main(String[] args) throws IOException {
29 HttpServer httpServer = startServer();
30 System.out.println(String.format("Jersey app started with WADL available at "
31 + "%sapplication.wadl\nTry out %shelloworld\nHit enter to stop it...",
32 BASE_URI, BASE_URI));
33 System.in.read();
34 httpServer.stop();
35 }
是否行33 「System.in.read()」 意味着它將被阻塞,直到有輸入?當使用UNIX rc腳本啓動Java應用程序時,這也會起作用 - 不是從命令行手動啓動的?
我想寫一個Java應用程序來偵聽HTTP連接。應用程序將在系統引導時自動啓動(使用UNIX rc腳本)。這意味着應用程序將持續運行 - 理論上永遠不會停止,直到有目的地停止。在Java main()方法中實現這個最好的方法是什麼?
不要停止'httpService'? –