fenerfan18
fenerfan18

Reputation: 153

How can RMI deadlock occur?

Assume that processes in a distributed application are using RMI for interactions between each other. How can deadlock occur? How to avoid it?

Upvotes: 2

Views: 779

Answers (2)

Hemkesh Jhamna
Hemkesh Jhamna

Reputation: 1

In the local JVM case, the JVM can tell that the calling object "A" owns the lock and will allow the call back to "A" to proceed. In the distributed case, no such determination can be made, so the result is deadlock. Distributed objects behave differently than local objects. If you simply reuse a local implementation without handling locking and failure, you will probably get unpredictable results. Since remote method invocation on the same remote object may execute concurrently, a remote object implementation needs to make sure its implementation is thread-safe. For example when one client logs on to the server in order to maintain security and to avoid deadlock the same customer will not be allowed to logon to the server from another machine. This is done by creating Session Flag.

Upvotes: 0

user207421
user207421

Reputation: 310980

You can get a deadlock via RMI in a system that doesn't deadlock without RMI if you use callbacks. A local callback is executed on the calling thread; however an RMI callback is executed on a different thread from the original client calling thread. So if there is client-side synchronization, a deadlock can occur that wouldn't occur if the calls were all local.

Upvotes: 2

Related Questions