Created
December 16, 2019 08:04
-
-
Save codekaust/7b8d86c3f7ad9612040d0a75ebe83ea7 to your computer and use it in GitHub Desktop.
Do not delete. It is used in my notes. It shows confusions that can occur while having multiple threads.
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
public class MultipleThreads{ | |
public static void main(String[] args) { | |
MyThread m = new MyThread(); | |
m.setName("m"); | |
m.run(); | |
m.start(); | |
MyThread m2 = new MyThread(); | |
m2.setName("m2"); | |
m2.run(); | |
m2.start(); | |
MyThread m3 = new MyThread(); | |
m3.setName("m3"); | |
m3.run(); | |
m3.start(); | |
} | |
} | |
class MyThread extends Thread{ | |
public void run(){ | |
System.out.println(Thread.currentThread().getName()); | |
} | |
public void start(){ | |
System.out.print("I am start: "); | |
super.start(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment