Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在创建一个 Java 一个简单的客户端/服务器程序,尽管两者都工作正常。问题是当客户端或服务器遇到错误时它会停止。有没有办法让我的客户端/服务器应用程序即使遇到错误也能持续运行?
您应该在循环中运行代码并在循环中捕获任何异常。例如
while (true) { try { //Do what ever your server does } catch (Exception e) { //Log your exception to a log file } }