Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- MyThread t1 = new MyThread(1);
- MyThread t2 = new MyThread(2);
- t1.start();
- t2.start();
- if(t1.isAlive()) {
- System.out.println("DA");
- t1.interrupt();
- }
- }
- }
- class MyThread extends Thread {
- int id;
- public MyThread(int _id) {
- id = _id;
- }
- @Override
- public void run() {
- for(int i = 0; i < 20; i++) {
- System.out.println("Thread " + id + " " + i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement