Created
July 8, 2020 10:06
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
Exchanger<String> exchanger = new Exchanger<>(); | |
Runnable laila = () -> { | |
try { | |
String messageFromMajnu = exchanger.exchange("I miss you Majnu!"); | |
} catch (InterruptedException e) { | |
Thread.currentThread.interrupt(); | |
throw new RuntimeException(e); | |
} | |
}; | |
Runnable majnu = () -> { | |
try { | |
String messageFromLaila = exchanger.exchange("I miss you too Laila"); | |
} catch (InterruptedException e) { | |
Thread.currentThread.interrupt(); | |
throw new RuntimeException(e); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment