Synchronization (The Java™ Tutorials > Essential Java Classes > Concurrency)
The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available. See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases. See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases. Threads communicate primarily by sharing access to fields and the objects reference fields refer to. This form of communication is extremely efficient, but makes two kinds of errors possible: thread interference and memory consistency errors. The tool needed to prevent these errors is synchronization. However, synchronization can introduce thread contention, which occurs when two or more threads try to access the same resource simultaneously and cause the Java runtime to execute one or more threads more slowly, or even suspend their execution. Starvatio
Synchronization (The Java™ Tutorials > Essential Java Classes > Concurrency) Documentation The Java™ Tutorials External Link --> Hide TOC Concurrency Processes and Threads Thread Objects Defining and Starting a Thread Pausing Execution with Sleep Interrupts Joins The SimpleThreads Example Synchronization Thread Interference Memory Consistency Errors Synchronized Methods Intrinsic Locks and Synchronization Atomic Access Liveness Deadlock Starvation and Livelock Guarded Blocks Immutable Objects A Synchronized Class Example A Strategy for Defining Immutable Objects High Level Concurre
related reading
- Memory Consistency Errors (The Java™ Tutorials > Essential Java Classes > Concurrency)docs.oracle.com
- Thread Interference (The Java™ Tutorials > Essential Java Classes > Concurrency)docs.oracle.com
- Synchronized Methods (The Java™ Tutorials > Essential Java Classes > Concurrency)docs.oracle.com
- LittleBookOfSemaphores.pdfgreenteapress.com
- Intrinsic Locks and Synchronization (The Java™ Tutorials > Essential Java Classes > Concurrency)docs.oracle.com
- Atomic Access (The Java™ Tutorials > Essential Java Classes > Concurrency)docs.oracle.com
- Reading 14: Concurrencyweb.mit.edu
- Reading 16: Mutual Exclusionweb.mit.edu
- A Concurrency Cost Hierarchytravisdowns.github.io
- The Go Memory Model - The Go Programming Languagego.dev
- C++11 Memory Modelpeople.cs.pitt.edu
- How to do distributed locking - Martin Kleppmann's blogmartin.kleppmann.com