Created
December 22, 2018 08:52
-
-
Save phoenix24/51718ded9c164cf8ba27a3a4435942a1 to your computer and use it in GitHub Desktop.
thread playground - tell me the output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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