Skip to content

Instantly share code, notes, and snippets.

@phoenix24
Created December 22, 2018 08:52
Show Gist options
  • Select an option

  • Save phoenix24/51718ded9c164cf8ba27a3a4435942a1 to your computer and use it in GitHub Desktop.

Select an option

Save phoenix24/51718ded9c164cf8ba27a3a4435942a1 to your computer and use it in GitHub Desktop.
thread playground - tell me the output.
public class SP4 {
public synchronized void func1() {
System.out.println("func1");
func2();
}
public synchronized void func2() {
System.out.println("func2");
func3();
}
public synchronized void func3() {
System.out.println("func3");
}
public static void main(String[] args) {
SP4 sp = new SP4();
Thread t = new Thread(new Runnable() {
@Override
public void run() {
sp.func1();
}
});
t.start();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment