...
Code Block | ||
---|---|---|
| ||
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="3dcaf341d596f2a0-f87ba638-45be462d-8d3c9e4a-2d938fc4bece6e932da9454c"><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="a9bfb532737d4323-80d5f6e4-4434458e-9b5fb02e-0cb4b1031e0dc3a524333480"><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="b0111d783d23d861-0e756fa6-4528445f-82918c0f-911c04cbc3c9929ef1807350"><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="7fc563648bdce69f-c3fa8986-483f4b16-8e6fba52-839a5952a7e4fffbf56a1a7a"><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="5ead1915b8307fff-45175b55-4c8241f4-a86798f0-b55adf2150d4a1563ed69aa0"><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="9dc7687987925002-ad4c2e1b-4d554f5d-b425bbb5-9abf05746ab8e67a7418ae2f"><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> |
...