package com.brilliance.isc.voltest;

import java.util.concurrent.TimeUnit;

/**
 * @author gechengyang
 * @date 2023/2/16
 */
public class VolatileDemo {
    public   static boolean stop = false;

    public static void main(String[] args)  {

        Thread thread = new Thread(() -> {

            int i = 0;

            while (!stop) {

                i++;
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(111);

            }

        }, "VolatileDemoThread") ;

        thread.start();

        System.out.println("start Thread");
        stop = true;
        try {
            TimeUnit.SECONDS.sleep(5);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //TimeUnit.MILLISECONDS.sleep(1);



    }
}
