Sunday, August 29, 2010

Threads and Callbacks in RMI

(from: http://www.cs.swan.ac.uk/~csneal/InternetComputing/ThreadCallBack.html)

7.1. Background

So far, all the RMI examples you have seen have been very straightforward - the client needs to invoke some service on a server, and is prepared to wait until the service has finished before proceeding. But what if the service will take some time, and the client wishes to get on with something else while it waits? Or if the activities of the server are to some degree independent of main function of the client? The first situation is often the case when dealing with GUI code - it is not considered good practice to freeze up a GUI while it performs some slow operation.
Also, suppose there are multiple clients - what happens if more than one tries to access the service at the same time? We will deal with this issue first, as it is the simplest.