2. Java Concurrency

Whenever more than one thread accesses a given state variable, and one of them might write to it, they all must coordinate their access to it using synchronization.

Brian Göetz

Java is one of the earliest languages in which concurrency is native. Built into the language at a low level are the constructs necessary for creating concurrent programs. In addition, as Java was conceived to be portable across multiple hardware architectures, it was also one of the first to define a memory model and to specify the exact behavior of its concurrent constructs.

Because Android’s concurrency constructs are built on Java’s, this chapter is a review of basic Java concurrency mechanisms. Of course, a complete description of the concurrency ...

Get Android™ Concurrency now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.