java吧 关注:1,224,526贴子:12,679,858
  • 2回复贴,共1

请问线程异常InterruptedException不调用Interrupt方法打断

取消只看楼主收藏回复

见下


IP属地:北京1楼2016-11-12 19:28回复
    package sda;
    public class BadThreads {
    static String message;
    private static class CorrectorThread
    extends Thread {
    public void run() {
    try {
    sleep(1000);
    } catch (InterruptedException e) {}
    // Key statement 1:
    message = "Mares do eat oats.";
    }
    }
    public static void main(String args[])
    throws InterruptedException {
    (new CorrectorThread()).start();
    message = "Mares do not eat oats.";
    Thread.sleep(2000);
    // Key statement 2:
    System.out.println(message);
    }
    }


    IP属地:北京2楼2016-11-12 19:29
    回复
      都没打断怎么就执行了呢,奇怪啊啊啊


      IP属地:北京3楼2016-11-12 19:29
      回复