【发布时间】:2011-09-16 14:13:59
【问题描述】:
我有以下 RMI 服务器代码:
public class ServerProgram {
public ServerProgram() {
try {
LocateRegistry.createRegistry(1097);
Calculator c = new CalculatorImpl();
String name = "rmi://host:port/name";
Naming.rebind(name, c);
System.out.println("Service is bound......");
} catch (Exception e) {
}
}
public static void main(String[] args) {
new ServerProgram();
}
}
当上述程序运行时,它会一直运行以等待客户端请求。但我不明白的是,是什么让该程序不在while(true){}; 之类的地方继续运行,以及如何阻止它监听,除了停止整个程序?
【问题讨论】: