The code is dumb because a mutex provides mutual exclusion only if competing threads fight over the same mutex. If each thread supplies its own mutex then there's no computation at all and every thread wins, which eliminates mutual exclusion.
A more apropriate implementation would be
class blob { private int cnt; private Object o = new Object(); void addOne() { synchronized (o) { cnt++; } }
Even this code is dumb, though, because there's no good reason, in this case, to create a second mutex each blob instance has its own mutex already.
This page last modified on 16 July 2003.