Java Performance Tuning
Java(TM) - see bottom of page
Our valued sponsors who help make this site possible
FREE Java Performance Troubleshooting Tool from AppDynamics. Download now!
New Relic: The first free APM tool with production profiler. Download now!
ManageEngine: End-to-End Java Performance Management. Download Product Now!
Performance tips for the Java volatile keyword
|
JProfiler
|
|
Get rid of your performance problems and memory leaks!
|
|
JENNIFER for APM
|
|
Monitor All Transactions in "Per-One-Second" Real-time. Download Now!
|
|
See Your Message Here
|
|
You could have your tool advertised here, to be seen by thousands of potential customers
|
|
AppDynamics
|
|
FREE Java Performance Troubleshooting Tool from AppDynamics. Download now!
|
|
New Relic
|
|
New Relic: The first free APM tool with production profiler. Download now!
|
|
ManageEngine
|
|
ManageEngine: End-to-End Java Performance Management. Download Product Now!
|
|
JProfiler
|
|
Get rid of your performance problems and memory leaks!
|
|
JENNIFER for APM
|
|
Monitor All Transactions in "Per-One-Second" Real-time. Download Now!
|
|
|
Java performance tuning tips relevent for using the volatile keyword.
Note however that volatile has been incompletely implemented in
most JVMs. Using volatile may not help to achieve the results
you desire (yes this is a JVM bug, but its been low priority until recently).
The following pages have their detailed tips extracted below
The following detailed tips have been extracted from the raw tips page
http://www-106.ibm.com/developerworks/java/library/j-threads1.html
When synchronization is required (Page last updated July 2001, Added 2001-07-20, Author Brian Goetz, Publisher IBM). Tips:
- You need to synchronize or make
volatile variables holding data that will be shared between threads.
http://developer.java.sun.com/developer/Books/performance2/chap3.pdf
Chapter 3 of "High Performance Java Computing : Multi-Threaded and Networked Programming", "Race Conditions and Mutual Exclusion" (Page last updated January 2001, Added 2001-02-21, Authors George Thiruvathukal, Thomas Christopher, Publisher Sun). Tips:
- NOTE THE TIP "volatile primitive datatypes have atomic ++ operations" HAS BEEN SHOWN TO BE INVALID
http://developer.java.sun.com/developer/Books/performance2/chap4.pdf
Chapter 4 of "High Performance Java Computing : Multi-Threaded and Networked Programming", "Monitors" (Page last updated January 2001, Added 2001-02-21, Authors George Thiruvathukal, Thomas Christopher, Publisher Sun). Tips:
volatile fields can be slower than non-volatile fields, because the system is forced to store to memory rather than use registers. But they may useful to avoid concurrency problems.
http://softwaredev.earthweb.com/java/article/0,,12082_951051,00.html
Multithreading and read-write locks, part 2 (Page last updated January 2002, Added 2002-01-25, Author Nasir Khan, Publisher EarthWeb). Tips:
- Volatile variables are always synchronized with the main memory copy.
http://developer.java.sun.com/developer/technicalArticles/Threads/applet/index.html
Introductory level article on threading applets (Page last updated March 2001, Added 2001-03-21, Author Monica Pawlan, Publisher Sun). Tips:
- The volatile modifier requests the Java VM to always access the shared copy of the variable so the its most current value is always read. If two or more threads access a member variable, AND one or more threads might change that variable's value, AND ALL of the threads do not use synchronization (methods or blocks) to read and/or write the value, then that member variable must be declared volatile to ensure all threads see the changed value.
Last Updated: 2012-02-02
Copyright © 2000-2012 Fasterj.com. All Rights Reserved.
All trademarks and registered trademarks appearing on JavaPerformanceTuning.com are the property of their respective owners.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the United States and other countries. JavaPerformanceTuning.com is not connected to Sun Microsystems, Inc. and is not sponsored by Sun Microsystems, Inc.
URL: http://www.JavaPerformanceTuning.com/tips/volatile.shtml
RSS Feed: http://www.JavaPerformanceTuning.com/newsletters.rss
Trouble with this page? Please contact us