I have Collections.synchronizedList of WeakReference, _components;
I wrote something like the following, expecting the intruder to complain:
public boolean addComponent2(Component e) { synchronized (_components) { return _components.add(new WeakReference<Component>(e)); } }
But the compiler is completely satisfied. Note that List.add () returns TRUE. So normal, any exit from the synchronized block releases the lock, but isn't this LOOK strange? This is like a “hole” in a block, similar to using return in a loop.
Would you be happy to support such code?
synchronized-block
Charlweed Nov 01 '11 at 19:44 2011-11-01 19:44
source share