Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyThread extends Thread {
- @Override
- public void run() {
- System.out.println(Thread.currentThread().getName());
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- System.out.println("Thread has been interrupted.");
- }
- }
- public static void main(String[] args) {
- for (int i = 0; i < 50; i++) {
- MyThread myThread = new MyThread();
- myThread.setName(String.valueOf(i + 1));
- myThread.start();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement