I need a code example for understanding of volatile keyword. I found some example on net but they are not working on my machine. Is there are any universal example for volatile that can run on all machines with same result.
Thanks in advance.
Thanks for reply. As per my understanding If a variable is declared as volatile it means when it used by a thread, then thread will go to main memory for getting its value not its local copy of that variable.
Joined: Jan 19, 2010
I got solution for my problem.
If it is not working on your machine just add more new ChangeListener().start(); to make CPU enough busy to force its threads to use local copy of variable.