[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: quick question on threads & remote stubs



On Mon, 02 Apr 2001, Reason wrote:
> >On Sun, 01 Apr 2001, Reason wrote:
> >> If two separate threads within the same JVM call
> >> ExternalDatabase.objectForName(name), do they receive references to the
> same
> >> stub object or to two different stub objects? In other words, does each
> >> different thread within a single JVM requesting an interface to the same
> >> persistant object require the creation of a new stub?
> >
> >Yes, each subsequent call of objectForName, regardless if this is in the
> same
> >or a different thread, creates and returns a new proxy object. proxy
> objects
> >are very small (6 bytes) so this should not be a problem. An object cache
> could
> >help to reduce the number of proxy objects in the VM but this would also
> add an
> >extra overhead to search in the cache each time a proxy is created.
> 
> Ok...how about references? e.g. you make an objectForName call for
> persistant object X that contains references to persistant objects Y and Z.
> You then get object Y via the reference and start working with it. In this
> case, do you get a new proxy object with every call in the same thread to
> the X.method() that returns Y?

It depends where you are 'start working with it'. If this is inside a method of
X (and so runs inside the server) then subsequent calls to X.method() will
return the same proxy object (the server tries to reduce the number of proxies
inside the VM). In contrast, if the method run inside the client and just
fetches the reference (proxy) of Y from X (which is for performance reasons bad
anyway), then you get a new proxy out of each call to X.method() that returns Y.

Note that proxies are immutable. It should make absolutely no difference to the
client if the same our different proxies are returned.

Did you encounter any problem with proxies?


Falko
-- 
______________________________________________________________________
Falko Braeutigam                              mailto:falko@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com