子线程会在while死循环么?取掉System.out.println(".");会么?请跑一遍后回答 ~_~

package com.aoptest.test;

import java.util.Date;

public class ProblemDemo {
    /*volatile*/ boolean flag = true;

    void test() {
        System.out.println("start");
        while (flag) {
            System.out.println(".");
        }
        System.out.println("end");
    }

    public static void main(String[] args) throws InterruptedException {
        ProblemDemo problemDemo = new ProblemDemo();
        new Thread(problemDemo::test).start();
        Thread.sleep(1000);
        problemDemo.flag = false;
        System.out.println("main end ");
    }
}


这个问题有人问过R大,去知乎看看R大的回答吧