Пример:
Код: Выделить всё
class X {
private int a;
private int b;
public synchronized void addA(){
a++;
}
public synchronized void addB(){
b++;
}
}
Подробнее здесь: https://stackoverflow.com/questions/304 ... -or-method
Код: Выделить всё
class X {
private int a;
private int b;
public synchronized void addA(){
a++;
}
public synchronized void addB(){
b++;
}
}