Answers for "where to use synchronized block and where to use synchronized methodin java"

5

synchronized java

synchronized blocks the next thread's call to method 
 as long as the previous thread's execution is not finished. 
  Threads can access this method one at a time. 
  Without synchronized all threads can access this method simultaneously.
Posted by: Guest on August-21-2021
3

synchronized block java

public class MyCounter {

  private int count = 0;

  public synchronized void add(int value){
      this.count += value;
  }
}
Posted by: Guest on January-13-2021

Code answers related to "where to use synchronized block and where to use synchronized methodin java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language