TCLUG Development Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [TCLUG-DEVEL:154] RMI give you multi-threading?
Bob Tanner <tanner@real-time.com> writes:
> I am struggling RMI and thread issues.
>
> Is a remote service via RMI automatically multi-threaded?
>
> Let's say there is a remote object that calculates PI to 1000 digits, lets
> call it calculatePI().
>
> If a single-threaded client #1 invokes the remote object's calculatePI(), I
> know client #1 will block on that method until a result comes back.
>
>
> So, we have client #1 waiting for calculatePI() to return and the remote
> object is crunching on the result. What happens if single-threaded client #2
> invokes calculatePI() ?
>
> A. Does client #2 block waiting for client #1's request to complete?
>
> B. Does the remote object accept client #2's request and start to process it (ie
> multi-threads)?
>
> My test programs seem to say A. is the case, but I cannot consistently
> duplicate the behavior. Any insights?
>
I would tend to agree with that, although some deep reading on the Java developer
connection would probably prove useful here. I seem to remember having real
problems with my last RMI project because of this. I ended up having to
sychronize a few more methods so that I could guarentee single threadedness.
You could synchronize the calculatePI() method to keep A from happening if you
would like.
--
Jon Schewe
http://eggplant.mtu.net/~jpschewe
schewe@tcfreenet.org