Last active
March 17, 2019 14:24
-
-
Save Yatharth0045/62543e8f94d9471cebd7b88c5222b30a to your computer and use it in GitHub Desktop.
Implementation of Thread by overriding the run method
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 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