public class Daemon {
/**
* 守护线程
*/
public static void main(String[] args) {
Thread t1 = new Thread() {
public void run() {
for (int i = 0; i < 2; i++) {
System.out.println(getName() + ".....aaaa");
}
}
};
Thread t2 = new Thread() {
public void run() {
for (int i = 0; i < 20; i++) {
System.out.println(getName() + ".....bbbb");
}
}
};
t2.setDaemon(true);
t1.start();
t2.start();
}
}
|
|