-
-
Save vinaymcu/befaa691f614c0244b1b8aa489f5f542 to your computer and use it in GitHub Desktop.
code
This file contains 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
class Shared { | |
synchronized void methodOne(Shared s) { | |
Thread t = Thread.currentThread(); | |
System.out.println(t.getName() + "is executing methodOne..."); | |
System.out.println(t.getName() + "is calling methodTwo..."); | |
s.methodTwo(this); | |
System.out.println(t.getName() + "is finished executing methodOne..."); | |
} | |
synchronized void methodTwo(Shared s) { | |
Thread t = Thread.currentThread(); | |
System.out.println(t.getName() + "is executing methodTwo..."); | |
System.out.println(t.getName() + "is calling methodOne..."); | |
s.methodOne(this); | |
System.out.println(t.getName() + "is finished executing methodTwo..."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment