Skip to content

Instantly share code, notes, and snippets.

@wkdalsgh192
Created July 11, 2021 10:14
Show Gist options
  • Save wkdalsgh192/a0667923b1aae321709b500216a3e946 to your computer and use it in GitHub Desktop.
Save wkdalsgh192/a0667923b1aae321709b500216a3e946 to your computer and use it in GitHub Desktop.
Thread newThread = new Thread(() -> {
System.out.println("Thread : "+ Thread.currentThread().getName());
try {
Thread.sleep(2000L);
} catch (InterruptedException e) {
System.out.println("Exit!");
return;
}
});
// join a thread work to a main thread
newThread.start();
newThread.join();
System.out.println(newThread+" is finished");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment