Skip to content

Instantly share code, notes, and snippets.

@vireshwali
Last active August 18, 2021 15:30
public class Temp2 {
private int age = 10;
private synchronized void hello(String name, int age){
String temp = "hello " + name + " there. ";
synchronized(this){
this.age = age;
}
System.out.println(temp + " Age: " + age);
}
public static void main(String[] args){
Temp2 t2 = new Temp2();
t2.hello("user_name", 20);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment