对于多线程环境中的这段代码,是否需要同步(c)?
SynchronizedCounter c = new SynchronizedCounter();
synchronized(c){
c.increment();
c.value();
}
public class SynchronizedCounter {
private int c = 0;
public synchronized void increment() {
c++;
}
public synchronized void decrement() {
c--;
}
public synchronized int value() {
return c;
}
}