Skip to content

Instantly share code, notes, and snippets.

@greekykhs
Created July 8, 2020 10:06
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