1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| public class TestDemon { public static void main(String[] args) { God god = new God(); YOU you = new YOU();
Thread thread = new Thread(god); thread.setDaemon(true); thread.start();
new Thread(you).start(); }
}
class God implements Runnable{
@Override public void run() { while (true) { System.out.println("上帝保护着你"); } } }
class YOU implements Runnable {
@Override public void run() { for (int i = 0; i < 36500; i++) { System.out.println("你一生都开学的活着"); } System.out.println("======goodbye! world!========"); } }
|