Jump to content

Java concurrency

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Red Thrush's Bot (talk | contribs) at 15:28, 10 December 2006 (Robot-assisted disambiguation: Thread). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Template:Linkless

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

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.