Archive Post

Defining Tasks That Return a Result – Concurrency: Part II

Defining Tasks That Return a Result Implementations of the java.util.concurrent.Callable<V> functional interface represent tasks that…

Invoking Tasks Collectively – Concurrency: Part II

Invoking Tasks Collectively Example 23.2 also illustrates invoking tasks collectively and handling the task results.…

Task Cancellation – Concurrency: Part II

Task Cancellation Task cancellation is an important aspect of controlling task execution. Here we look…

The Fork/Join Framework 2 – Concurrency: Part II

Table 23.3 Task-Defining Classes Classes in the java.util.concurrent package to define tasksDescriptionForkJoinTask<V>Abstract class that defines…

Writing Thread-Safe Code – Concurrency: Part II

23.4 Writing Thread-Safe Code Thread-safety is a critical property of a concurrent application. Threads can…

Immutability 2 – Concurrency: Part II

All reads and writes are atomic actions for all volatile fields, regardless of whether they…

Atomic Variables 2 – Concurrency: Part II

The while loop ensures that the value is always incremented by 1 from the previous…

Reentrant Lock – Concurrency: Part II

Reentrant Lock The ReentrantLock class implements the Lock interface. Instances of the Reentrant-Lock class are…

Reentrant Read-Write Lock – Concurrency: Part II

Reentrant Read-Write Lock The explicit lock implemented by the ReentrantLock class is mutually exclusive—that is,…

Special-Purpose Synchronizers 2 – Concurrency: Part II

Example 23.14 illustrates using a single cyclic barrier that is shared by three threads. The…