synchronized block example in java
Example: synchronized block java
public class MyCounter {
private int count = 0;
public synchronized void add(int value){
this.count += value;
}
}
public class MyCounter {
private int count = 0;
public synchronized void add(int value){
this.count += value;
}
}