On Wed, 30 May 2012 17:42:47 -0400, José Armando García Sancio <jsan...@gmail.com> wrote:

On Wed, May 30, 2012 at 5:30 PM, Steven Schveighoffer
<schvei...@yahoo.com> wrote:
All deadlocks involving A and B mutexes. Or if not, can you show how? I
can't see it.

-Steve

This can cause a deadlock because locking order is not guaranteed, no?

synchronized class A {
  void delegate(B b) { b.call() }
  void call() {}
}

synchronized class B {
  void delegate(A a) { a.call() }
  void call() {}
}

Thanks,
-Jose
PS. This may not compile not sure if it should be 'void
delegate(shared B b)', etc.

A and B are not modifiable. Given the implementation of A and B that I gave, how can you achieve deadlock?

The big problem I see with allowing anyone to synchronize on A and B is that one cannot achieve the property of "not possible to use me in a deadlock."

-Steve

Reply via email to