mastodilu
mastodilu

Reputation: 119

Does local method call wait for remote return value in java RMI?

I have a question about how local and remote methods cooperate in Java RMI. Here's the ideal situation:

localClass.setValue(server.getValue());

Does localClass.setValue(..) awaits for the return value from the server or do I have to make sure of it using some sort of synchronization in local? What happens if the server needs like 5 seconds to execute getValue()?

Upvotes: 1

Views: 625

Answers (2)

user207421
user207421

Reputation: 310980

Not quite.

Arguments are evaluated left to right before the method is called.

So localClass.setValue() isn't even called until the parameter value returned by server.getValue() is available. So the client waits as long as that takes, and then calls localClass.setValue(). It isn't setValue() that does the waiting, it is the stub's call to server.getValue().

You don't have to do anything about it yourself.

Upvotes: 1

Lorenzo Imperatrice
Lorenzo Imperatrice

Reputation: 997

The client wait the 5 sec, if you would like to set a timeout exception you have to do it by yourself like already suggested in this question.

Upvotes: 0

Related Questions