class Runner {
  public static void main(String[] args) throws InterruptedException {    Thread myThread = new Thread(new Thread() {
      @Override
      public void run() {
//        for (int i = 0; i < 2; i++) {
//        System.out.println(((Thread) this).isInterrupted());
        System.out.println("第1次调用Thread.interrupted(),返回值:" + Thread.interrupted());
        System.out.println("第2次调用Thread.interrupted(),返回值:" + Thread.interrupted());
        System.out.println("第3次调用Thread.interrupted(),返回值:" + Thread.interrupted());
        System.out.println("第4次调用Thread.interrupted(),返回值:" + Thread.interrupted());
        System.out.println("============end===================");
//        }
      }
    });    ExecutorService service = Executors.newCachedThreadPool();
    service.execute(myThread);
//    Thread.sleep(1000);
    service.shutdownNow();
    System.out.println("shutdownNow");
  }}result :
第1次调用Thread.interrupted(),返回值:true
shutdownNow
第2次调用Thread.interrupted(),返回值:true
第3次调用Thread.interrupted(),返回值:false
第4次调用Thread.interrupted(),返回值:false
============end===================以上是测试代码和结果,我疑惑的是:在调用shutdowmNow之后,应该只会出现一次返回值为true,为什么这里会有2次,但是
jdk中是native代码,我不会看。我猜测是否是内存中未及时刷新,导致的内存的可见性问题?请教大神解答。