I have noticed a few times that Java implements synchronized blocks thusly:
aload 4
dup
astore 5
monitorenter
[ various instructions ]
aload 5
monitorexit
Why does it duplicate the variable when running synchronized blocks?
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth