Is there a mistake in this example of Volatile? How do you run it to keep it running?

would like to ask you gods, I want to get a use case of Volatile, this is the following code, according to the following code,
if I set the jvm run parameter to-server, it should always run, the program will enter an endless loop, but in fact
does not, this is why?

public class Main {


    public static void main(String[] args) {

        VolatileThread volatileThread = new VolatileThread();
        volatileThread.start();


        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        volatileThread.setContinue(false);

    }



}
 
public class VolatileThread extends Thread{

    private boolean isContinue = true;

    public void setContinue(boolean aContinue) {
        isContinue = aContinue;
    }

    @Override
    public void run() {


        while (isContinue){
            System.out.println("Continue");
        }

        System.out.println("end");

    }


}

I use IDEA to run the program. The following is a picture of my setting of running parameters:

is my parameter not set correctly? Or is the example incorrect?

Dec.14,2021

even if you don't add the volatile keyword to isContinue , JVM will eventually send the modified isContinue value Synchronize to other threads, and volatile will just notify other threads of the change to the shared data immediately.

if you want to keep the program running, you can change it like this:

public class VolatileThread extends Thread {
    private boolean isContinue = true;
    public void setContinue(boolean aContinue) {
        isContinue = aContinue;
    }
    @Override
    public void run() {
        boolean localContinue = isContinue;
        while (localContinue){
            System.out.println("Continue");
        }
        System.out.println("end");
    }
}
Menu