This is a common topic here. Many candidates ignore the problem, however you will find many topics discussing using the Unreferenced interface (for RMI), WeakHashMap (for RMI or Sockets), or catching the exception when a socket disconnects (for Sockets) to handle this.
Unreferenced is an RMI interface - aren't you developing a Sockets solution?
If you are using RMI, have you developed an Remote Factory so that each client gets their own Remote object?
Joined: Jan 25, 2006
Hi Andrew, Before last week I used Socket, and this week i just want to try RMI.While using Socket, my server-clients can run only under assistance of multithread.And this week i found that mulity clients need not have to use multithread if i use RMI.I didnot use RMI Factory, and could you show me the advantage when using RMI Factory.
author and jackaroo
For your purposes, the main advantage for having an RMI Factory creating Remote objects is that each Remote object can implement the Unreferenced interface. Then, when a client disconnects (whether deliberately, because of network problems, or because of a crash) the unreferenced() method will be called, which gives you an opportunity to clean up stale (or orphaned) locks.
An example of using an RMI Factory and the Unreferenced interface is shown in the topic "Rmi question" - note that this does not walk you through the code, but just presents it and leaves it to the reader to ask questions.
subject: URLyBird: Timer to unlock locked records when client crash