Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Do i have to use 'synchronized' for server methods?

7 views
Skip to first unread message

Michael Justin

unread,
Aug 20, 2004, 7:14:15 AM8/20/04
to
Hello newsgroup,

in my RMI server object, i use a HashTable to manage session objects
which allow to set/get a session-ID, some 'session values' and other
things for each connected client.

Do i have to make the getSessionValue / setSessionValue methods
synchronized or does RMI synchronize the access to these server methods
somehow "automagically"?

Thanks in advance!

Mike

Brenton Camac

unread,
Aug 30, 2004, 12:13:59 PM8/30/04
to Michael Justin
Michael,

unfortunately no automagical capabilities (by default) in RMI.

If multiple RPC requests arrive at the RMI server concurrently for the
same RMI object then there will be concurrent invocations on that
object. That is, RMI server-side logic does not serialize (in the sense
of allowing only one through at a time / viz. transaction serialization)
the RPC method invocations it receives. I believe this is the
automagical functionality you were hoping for.

One approach to resolve this would be to simulate
invocation-serialization by limiting the number of service threads RMI
will use to just one. Then there would only ever be one call active in
the server. However, this would severely restrict the server's ability
to scale to handle more than one client, so this approach isn't recommended.

A better approach is to protect those data structures in your
application which are not designed for concurrent access with
synchronization blocks, etc. This is what you correctly assumed.

rgds,
Brenton

--
Brenton Camac
Consultant
Camac IT Ltd

Michael Justin

unread,
Sep 8, 2004, 1:07:53 PM9/8/04
to
Brenton Camac wrote:

> If multiple RPC requests arrive at the RMI server concurrently for the
> same RMI object then there will be concurrent invocations on that
> object.

Instead of one remote RMI object on the server which is shared by all
clients, i could create a factory method in the server which creates one
server-side RMI object for every client. So this object would be used
exclusively by the client who creates and holds a reference to it? Could
be simple to implement and use.

Michael

Mo Tahmasebi

unread,
Jan 4, 2005, 5:06:55 PM1/4/05
to
Sorry guys but I did not get the reply to this question! Could you let me
know the answer too?

Thanks
Mo

"Michael Justin" <michael...@postkasten.de> wrote in message
news:4125...@newsgroups.borland.com...

Paul Furbacher [TeamB]

unread,
Jan 6, 2005, 11:07:16 PM1/6/05
to
Mo Tahmasebi wrote:

> Sorry guys but I did not get the reply to this question! Could you
> let me know the answer too?

The best thing to do is to check the archives
to see whether anyone answered the question.
If not, it could be that no one really has
a good answer.


--


Paul Furbacher (TeamB)

Save time, search the archives:
http://www.borland.com/newsgroups/ngsearch.html

Is it in Joi Ellis's Faq-O-Matic?
http://www.visi.com/~gyles19/fom-serve/cache/1.html

Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.

abderrah...@gmail.com

unread,
Oct 14, 2014, 7:32:50 PM10/14/14
to
By default, a Hashtable is synchronized, so only one thread can access the table at a time.
0 new messages