Wiki Markup |
---|
Compound operations are operations that consist of more than one discrete operation. Expressions that include postfix or prefix increment ({{\+\+}}), postfix or prefix decrement ({{\-\-}}), or compound assignment operators always result in compound operations. Compound assignment expressions use operators such as {{\*=, /=, %=, \+=, \-=, <<=, >>=, >>>=, \^=}} and {{\|=}} \[[JLS 2005|AA. JavaBibliography#JLS References#JLS 05]\]. Compound operations on shared variables must be performed atomically to prevent [data races|BB. Definitions#data race] and [race conditions|BB. Definitions#race conditions]. |
...
Wiki Markup |
---|
This approach may not be used when a getter method performs operations other than just returning the value of a volatile field without having to use any synchronization. Unless read performance is critical, this technique may not offer significant advantages over synchronization \[[Goetz 2006|AA. JavaBibliography#Goetz References#Goetz 06]\]. |
Guideline VNA06-J. Do not assume that declaring an object reference volatile guarantees visibility of its members also addresses the volatile-read, synchronized-write pattern.
...
Wiki Markup |
---|
Read-write locks allow shared state to be accessed by multiple readers or a single writer but never both. According to Goetz \[[Goetz 2006|AA. Java References#GoetzBibliography#Goetz 06]\] |
In practice, read-write locks can improve performance for frequently accessed read-mostly data structures on multiprocessor systems; under other conditions they perform slightly worse than exclusive locks due to their greater complexity.
...
Wiki Markup |
---|
\[[API 2006|AA. Java References#APIBibliography#API 06]\] Class AtomicInteger \[[JLS 2005|AA. Java References#JLSBibliography#JLS 05]\] [Chapter 17, Threads and Locks|http://java.sun.com/docs/books/jls/third_edition/html/memory.html], Section 17.4.5 Happens-Before Order, Section 17.4.3 Programs and Program Order, Section 17.4.8 Executions and Causality Requirements \[[Tutorials 2008|AA. JavaBibliography#Tutorials References#Tutorials 08]\] [Java Concurrency Tutorial|http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html] \[[Lea 2000|AA. JavaBibliography#Lea References#Lea 00]\] Section 2.2.7 The Java Memory Model, Section 2.1.1.1 Objects and Locks \[[Bloch 2008|AA. Java References#BlochBibliography#Bloch 08]\] Item 66: Synchronize access to shared mutable data \[[Goetz 2006|AA. Java References#GoetzBibliography#Goetz 06]\] 2.3. "Locking" \[[MITRE 2009|AA. Java References#MITREBibliography#MITRE 09]\] [CWE ID 667|http://cwe.mitre.org/data/definitions/667.html] "Insufficient Locking," [CWE ID 413|http://cwe.mitre.org/data/definitions/413.html] "Insufficient Resource Locking," [CWE ID 366|http://cwe.mitre.org/data/definitions/366.html] "Race Condition within a Thread," [CWE ID 567|http://cwe.mitre.org/data/definitions/567.html] "Unsynchronized Access to Shared Data" |
...