Skip to content

Instantly share code, notes, and snippets.

@Yatharth0045
Last active March 17, 2019 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yatharth0045/62543e8f94d9471cebd7b88c5222b30a to your computer and use it in GitHub Desktop.
Save Yatharth0045/62543e8f94d9471cebd7b88c5222b30a to your computer and use it in GitHub Desktop.
Implementation of Thread by overriding the run method
class MyThread {
public static void main(String[] args) {
for (int count = 0; count < 10; count++) {
Thread thread = new Thread(() -> {
System.out.println(Thread.currentThread().getName() + ": Child Thread");
});
thread.start();
}
for (int count = 0; count < 10; count++) {
System.out.println(Thread.currentThread().getName() + ": Main Thread " + count);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment