class Counter { private int value; Counter() { set(0); } Counter(int v) { set(v); } void set(int v) { value = v; } synchronized void inc(int increment) { value += increment; } synchronized void inc() { ++value; } synchronized void dec(int decrement) { value -= decrement; } synchronized void dec() { --value; } synchronized boolean decIfGreaterThan(int low) { if (value > low) { --value; return true; } return false; } synchronized boolean incIfLessThan(int high) { if (value < high) { ++value; return true; } return false; } }