Instantiate more than one RMI object

0

I made an application using RMI, however, I need the objects to be started at the same time. In the way I know how to do it, I start for example 5 objects, but in the loop one only starts after the other ends.

Follow the client snippet.

Thanks for the help right away.

import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry;

public class HelloClient {     private static final long serialVersionUID = 1L;

static String resultNodes[];

public static void nodeProcessor(String server, int port){
    try {
        String result = "";

        Registry registry = LocateRegistry.getRegistry(server, port);
        Hello obj = (Hello) registry.lookup("Helo");            
        result = obj.Hello();   
        System.out.println(result); 
    } 
    catch (Exception e) { 
        System.out.println("HelloClient exception: " + e.getMessage()); 
        e.printStackTrace(); 
    } 

}

public static void main(String args[]){ 
    try {
            System.setProperty("java.security.policy","java.policy");
        if (System.getSecurityManager() == null) {
            System.setSecurityManager(new SecurityManager());
        }   

        String serverPort[];

        //nodeProcessor(server, port);

        ListNodes listNodes = new ListNodes();
        resultNodes = listNodes.listNodesRet();

        for (int i = 0; i < resultNodes.length; i++) {
            if (resultNodes[i] != null) {
                serverPort = resultNodes[i].split(",");
                nodeProcessor(serverPort[0], (new Integer(serverPort[1])).intValue());
                System.out.println("Enviado para " + serverPort[0] + ":" +serverPort[1]);
            }
        }
    } 
    catch (Exception e) { 
        System.out.println("HelloClient exception: " + e.getMessage()); 
        e.printStackTrace(); 
    } 
} 

}

    
asked by anonymous 16.04.2018 / 14:49

0 answers