Content about Java ERP Solution for Reviews Best ERP Software for sale and Free Software with Java OpenSource for Free Download

Java synchronized block vs synchronized method

You can using synchronized  to lock multi Thread program with process thread by thread

Example code for using synchronized block and synchronized  method

synchronized  method

public synchronized void testMethod(String obj){
    // you method logic  
}

synchronized block
public void testMethod(String obj){
    // your method logic
    synchronized(this){
        // your method logic
        // your method logic
    }
    // your method logic
    // your method logic
    synchronized(Test.class){
        // your method logic
        // your method logic
    }
    // your method logic
}