Rmi & Concurrency

I was wondering if the rmi - server calls are synchronized.

Example:

A remote server with this method:

int number;

public int getNumber() throws RemoteException{

number++;

return number;

}

If multiple clients call the server, can they get the same number?

Or should I synchronize the methods?

[355 byte] By [Carraa] at [2007-11-27 10:32:40]
# 1

The RMI Runtime uses a thread for each call. Therefore, you need to protect your class variables.

Synchronization at the method level locks out all the work within the method. You MAY BE better off only locking out the code that actually needs locking. For your int value, try using java.uti.concurrent..AtomicInteger()

cooper6a at 2007-7-28 18:18:05 > top of Java-index,Core,Core APIs...