Search code examples
javamultithreadingrmi

RMI Threadfactory


Is it possible to assign a Custom Thread Factory to the RMI server. I currently use the following code:

    try {
        String sName = InetAddress.getLocalHost().getHostName();
        thisAddress = (InetAddress.getLocalHost().toString());
    } catch (UnknownHostException ex) {
    shutdown();
    }
    thisport = 8081;

    registry = LocateRegistry.createRegistry(thisport);
    registry.rebind("rmiserver", this);
    System.out.println("Listening on " + thisAddress + " at port " + thisport);

However, I would like to set that the threads created are not standard Threads but a sub-class of the same.

Regards, KT


Solution

  • No, you can't control the threads created by the RMI runtime system. It doesn't use a thread factory at all actually, just new Thread(...).

    EDIT: I should clarify that I am speaking of the Sun implementation of RMI/JRMP. I have heard that the IBM implementation uses a thread pool, and I can't speak for what happens in RMI/IIOP at all, there being so many possible providers.