Type a synchronized increment method
Type a synchronized increment method
Answer
private int count = 0; public synchronized void increment() { count++; }
synchronized on a method uses `this` as the monitor. Only one thread at a time can execute any synchronized method on the same Counter instance.