Re: multiple clients connecting to RMI server

Niclas Hedhman <[email protected]> Mon, 23 Feb 2009 14:08:07 +0800
Newsgroups gmane.comp.java.sun.rmi
Message-ID <[email protected]>
On Mon, Feb 23, 2009 at 1:50 PM, titu <[email protected]> wrote:

> Is RMI server multi threaded by default or creates separate instances when
> multiple client access it simultaneously?
> Or do we need to take care of data structures whenever a new connection is
> getting set?

Each object is exported explicitly in your code, and RMI is
thread-safe so to speak that its internals can handle multiple
incoming calls to the same exported object. It also means that your
code must be made thread-safe accordingly. If that is a problem, then
a typical setup would be that the main 'server' creates and exports
one object per session, which each client use explicitly. It is quite
ok to hand out a lot of exported objects to clients, as each client
JVM will try to minimize the use of sockets and interleaves multiple
conversations over the same socket (if possible).

Cheers
Niclas
-- 
http://www.qi4j.org - New Energy for Java

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff RMI-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

For a list of frequently asked RMI questions please refer to:
http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html

To view past RMI-USERS postings, please see:
http://archives.java.sun.com/archives/rmi-users.html