Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The <code>volatile</code> and <code>transient</code> modifiers apply to fields of classes.</p> <p>The <code>transient</code> modifier tells the Java object serialization subsystem to exclude the field when serializing an instance of the class. When the object is then deserialized, the field will be initialized to the default value; i.e. <code>null</code> for a reference type, and zero or <code>false</code> for a primitive type. Note that the JLS (see <a href="http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.3.1.3" rel="noreferrer">8.3.1.3</a>) does not say what <code>transient</code> means, but defers to the <a href="http://download.oracle.com/javase/6/docs/platform/serialization/spec/serialTOC.html" rel="noreferrer">Java Object Serialization Specification</a>. Other non-standard serialization mechanisms may also pay attention to a field's <code>transient</code>-ness. </p> <p>The <code>volatile</code> modifier tells the JVM that writes to the field should always be synchronously flushed to memory, and that reads of the field should always read from memory. This means that fields marked as volatile can be safely accessed and updated in a multi-thread application without using native or standard library-based synchronization. Similarly, reads and writes to volatile fields are atomic. (This does not apply to >>non-volatile&lt;&lt; <code>long</code> or <code>double</code> fields, which may be subject to "word tearing" on some JVMs.) The relevant parts of the JLS are <a href="http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.3.1.4" rel="noreferrer">8.3.1.4</a>, <a href="http://java.sun.com/docs/books/jls/third_edition/html/memory.html#17.4" rel="noreferrer">17.4</a> and <a href="http://java.sun.com/docs/books/jls/third_edition/html/memory.html#17.7" rel="noreferrer">17.7</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload