Skip to main content

RMI Interruptus! - Interrupting RMI method calls

Posted by neilotoole on April 21, 2006 at 6:02 PM PDT

The Interruptible RMI library provides a mechanism to interrupt RMI calls. Typically when a thread invokes an RMI method, the thread blocks until the RMI method returns. If the method call is taking too long (e.g. if the RMI server is busy, or hangs, or if the user wants to cancel the RMI operation), there is no easy way to interrupt the blocking RMI call and return control to the RMI thread. The Interruptible RMI library provides this functionality.

The library consists of two key components: an RMISocketFactory and a ThreadFactory. RMI calls made on a thread from the provided ThreadFactory to an RMI interface using sockets from the RMISocketFactory can be interrupted by calling Thread#interrupt() on the client thread. So, it's really easy to use. But note also on the server side that you may wish to add a call to a handy utility method to ensure that the current thread isn't a "zombie" or orphaned thread that has already been "interrupted" by the client. There is a demo app provided with the library that shows exactly how to do this. See the Interruptible RMI project page for more details and to download the library and demo app.

Related Topics >>