目标是在调用 System.exit(0);
之前将一些消息打印到终端,例如:
System.out.println("Stopping the server...");
System.exit(0);
但是应用程序在打印消息之前退出。如何同步呢?使用Java JDK8 SE。
最佳答案
您必须flush()退出应用程序之前的流。
System.out.println("Stopping the server...");
System.out.flush();
System.exit(0);
关于java - 如何在 System.exit(0) 之前打印一行到终端?同步问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50896182/