We\'re doing some prototyping work and we\'re wondering if it is possible to interrupt a thread that performed an RMI call. If we call interrupt() on this thread, would it throw
No, interrupt()
won't work here, since RMI uses blocking java.io
, which is non-interruptable.
Your options are either to send another RMI call to the server on a separate thread, which asks it to interrupt the processing the call programmatically (assuming the server-side code is performing an interruptible loop of some kind).
Alternatively perform the original RMI call in a separate thread, which you can then "discard" if required. Using a java.util.concurrant.ExecutorService
would seem useful here, since it allows you to submit a task and wait for a finite time for it to complete. The actual RMI call wouldn't be interrupted, but your client program could still continue.