Java concurrency
Introduction
Java is a programming language (and API) which has been designed to support concurrent programming, and all execution in the language takes place in the context of a thread. It is important for a Java programmer to understand both the power and limitations of Java threads.
In the JVM (Java Virtual Machine), objects and resources can be accessed by many separate threads; each thread has its own path of execution but can potentially access any object in the program. The programmer must to ensure that threads do not interfere with each other, and that resources are properly coordinated (or "synchronized") during both read and write access. The Java language has built-in constructs to support this coordination.
The Java Language Specification does not say how the JVM designer should implement the multithreading primitives specified, because there is so much variation among the various operating systems and hardware on which the JVM is expected to run.
Monitor synchronization in Java
They key synchronization concept in Java is that of a monitor. Every object in a JVM has a monitor associated with it.
Changes in Java 5
Java 5 incorporated many additions and clarifications to the Java concurrency model. JSR 133 provided support for well-defined atomic operations in a multithreaded/multiprocessor environment, opening the door to JSR 66, a large battery of concurrent programming APIs.
See also
- Monitor (synchronization)
- Concurrency (computer science)
- Concurrency pattern
- Doug Lea
- Thread (computer science)
- K-means
References
- Goetz, Brian (2006). Java Concurrency in Practice. Addison Wesley. ISBN 0321349601.
{{cite book}}
: Unknown parameter|coauthors=
ignored (|author=
suggested) (help) - Lea, Doug (1999). Concurrent Programming in Java: Design Principles and Patterns. Addison Wesley. ISBN 0201310090.
External links
- JDK 5.0 concurrency utilities
- Podcast from JavaPolis - 'Concurrency Utilities in JDK 5.0 by Brian Goetz'
- JavaOne 2005 - Concurrency Utilities in Practice
- JavaOne 2005 - Brian Goetz - Simpler, Faster, Better: Concurrency Utilities in JDK™ Software Version 5.0
- Podcast from JavaPosse - Interview with Brian Goetz on Concurrency in Java 5
- William Pugh's Java Memory Model page