先收拾房间再睡觉

    1. public class Main{
    2. public static void main(String[] args){
    3. System.out.println("main: BEGIN");
    4. try{
    5. CountupThread t = new CountupThread();
    6. t.start();
    7. //稍微间隔一段时间
    8. TimeUnit.SECOND.sleep(10);
    9. //线程的终止请求
    10. System.out.println("main: shutdownRequest");
    11. t.shutdownRequest();
    12. System.out.println("main: join");
    13. //等待线程终止
    14. t.join();
    15. }catch(InterruptedException e){
    16. e.printStackTrace();
    17. }
    18. System.out.println("main: END");
    19. }
    20. }