Из-за чего потоки продолжают работать? Где что нужно закрыть, чтобы потоки остановились?
(Метод clientService.doubleString("str") просто выдаёт строку "strstr")
package com.javarush.task.task32.task3207;
import java.rmi.AlreadyBoundException;
import java.rmi.NotBoundException;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
public class Solution {
public static final String UNIC_BINDING_NAME = "double.string";
public static Registry registry;
// Pretend we're starting an RMI client as the CLIENT_THREAD thread
public static Thread CLIENT_THREAD = new Thread(new Runnable() {
@Override
public void run() {
try {
DoubleString clientService = (DoubleString) registry.lookup(UNIC_BINDING_NAME);
String result = clientService.doubleString("str");
System.out.println(result);
} catch (RemoteException e) {
throw new RuntimeException(e);
} catch (NotBoundException e) {
throw new RuntimeException(e);
}
}
});
public static void main(String[] args) throws InterruptedException {
// Pretend we're starting an RMI server as the main thread
Remote stub = null;
try {
registry = LocateRegistry.createRegistry(2099);
final DoubleStringImpl service = new DoubleStringImpl();
stub = UnicastRemoteObject.exportObject(service, 0);
registry.bind(UNIC_BINDING_NAME, stub);
} catch (RemoteException e) {
e.printStackTrace();
} catch (AlreadyBoundException e) {
e.printStackTrace();
}
// Start the client
CLIENT_THREAD.start();
}
}