It appears to be difficult unless one accept some limitations.
If the expression in synchronized() evaluates to a normal svalue it's too late to go back to the variable it came from. To avoid that it'd be necessary to evaluate to an lvalue, but that won't work in cases like synchronized(my_object->foo) where my_object has a custom `->.
I don't think that's a major shortcoming, though; in such odd cases one can just give the mutex a name of its own.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-02-05 18:33: Subject: synchronized
That looks nicer then my solution. If you can get that to work, I'm all for it. It also has the benefit that it will syncrhonize on the variable, not the value.
/ Mirar