package com.itheima.threaddemo8;
public class Demo {
public static void main(String[] args) {
MyThread1 t1=new MyThread1();
MyThread2 t2=new MyThread2();
t1.setName("女神");
t2.setName("备胎");
t2.setDaemon(true);
t1.start();
t2.start();
}
}
package com.itheima.threaddemo8;
public class MyThread1 extends Thread {
@Override
public void run() {
for (int i = 0; i < 10; i++) {
System.out.println(getName()+"----"+i);
}
}
}
package com.itheima.threaddemo8;
public class MyThread2 extends Thread {
@Override
public void run() {
for (int i = 0; i < 100; i++) {
System.out.println(getName()+"----"+i);
}
}
}
|