This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.