Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
final class Flag {
  private volatile boolean flag = true;

  public synchronized void toggle() {
    flag ^= true; // Same as flag = !flag;
  }

  public boolean getFlag() {
    return flag;
  }
}

Wiki Markup
This approach is forbiddenmust not be used for getter methods that perform any additional operations other than  returning the value of a volatile field without use of synchronization. Unless read performance is critical, this technique may lack significant advantages over synchronization \[[Goetz 2006|AA. Bibliography#Goetz 06]\].

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="444eaa558fe7a24f-42f94403-49634629-a2a1b56c-7da34177803ef41ad2d19d02"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API 06]]

Class AtomicInteger

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="65cbddd27b8f6ae0-d1eead43-45ca47ae-9ccb8a96-a138e2c9bcf8bbe037eb4c83"><ac:plain-text-body><![CDATA[

[[Bloch 2008

AA. Bibliography#Bloch 08]]

Item 66: Synchronize access to shared mutable data

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="05899a4c0cc86931-eb540c8f-4e964c81-84dfa863-4048448fa916efba5ed17e71"><ac:plain-text-body><![CDATA[

[[Goetz 2006

AA. Bibliography#Goetz 06]]

2.3. "Locking"

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6863169d9bca3318-33454eda-49354c3c-a999ac3f-508f92a3ced38a09fc0863bd"><ac:plain-text-body><![CDATA[

[[JLS 2005

AA. Bibliography#JLS 05]]

[Chapter 17 Threads and Locks

http://java.sun.com/docs/books/jls/third_edition/html/memory.html], ]]></ac:plain-text-body></ac:structured-macro>

 

Section 17.4.5 Happens-Before Order

 

Section 17.4.3 Programs and Program Order

 

Section 17.4.8 Executions and Causality Requirements

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="e0fbb365eb10dc27-4fc78e8d-409b4134-9129add0-2cd035918b1e4747ea682b83"><ac:plain-text-body><![CDATA[

[[Lea 2000

AA. Bibliography#Lea 00]]

Section 2.2.7 The Java Memory Model

]]></ac:plain-text-body></ac:structured-macro>

 

Section 2.1.1.1 Objects and Locks

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="4170811e3f257288-eea81d42-45554a0b-a69f856a-29e1c0513abd2c1d739f121f"><ac:plain-text-body><![CDATA[

[[Tutorials 2008

AA. Bibliography#Tutorials 08]]

[Java Concurrency Tutorial

http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html]

]]></ac:plain-text-body></ac:structured-macro>

...