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 wrote:
> I am struggling RMI and thread issues.
>
> Is a remote service via RMI automatically multi-threaded?
No, I don't believe so. That was one of the value propositions of an EJB container
was that the EJB container would handle the multi-threading for you.
>
>
> 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() ?
Both clients have reference to the same object? I have not used RMI much, is RMI
inherently thread-safe? Or do you have to specify synchronized to protect methods
against multi-client access
>
>
> 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?
Sorry, no insights here on RMI.
--
Perry Hoekstra
---
"I don't see much sense in that," said Rabbit.
"No," said Pooh humbly, "there isn't. But there was going to be when I began it.
It's just that something happened to it along the way."