Chapter 21. Multithreaded Clients

Up until this point, we’ve assumed that there’s a sharp distinction between clients and servers. Our clients have been simple applications and make easily handled calls to servers in response to user actions. This model, while a good starting point, often leads to clumsy user interfaces. In this chapter, we explore ways to build more sophisticated clients. Along the way, we’ll revisit our threading assumptions and talk again about remote iterators.

Different Types of Remote Methods

Consider, once again, the Account interface:

public interface Account extends Remote {
	public Money getBalance(  ) throws RemoteException;
	public void makeDeposit(Money amount) throws RemoteException,
         NegativeAmountException;
	public void makeWithdrawal(Money amount) throws RemoteException,
         OverdraftException, NegativeAmountException;
}

Each of the methods contained in the Account interface shares the following five characteristics:

  • Their arguments don’t require a lot of bandwidth to send over the wire.

  • Actually performing the business logic doesn’t require much computational effort on the part of the server.

  • All the methods require similar amounts of bandwidth and computational effort. Distinct calls, even ones from different clients accessing different accounts, have the same computational profile.

  • They require a timely response.

  • It’s hard to say that one request is more important than another.[92]

When all five of these characteristics are present, requests are fairly ...

Get Java RMI now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.