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…

Submitting Tasks Individually – Concurrency: Part II

Submitting Tasks Individually Example 23.2 illustrates submitting tasks individually and handling the task result. A…

Scheduling Periodic Tasks – Concurrency: Part II

Scheduling Periodic Tasks The ScheduledExecutorService interface provides two methods that can be used to schedule…

Task Cancellation 2 – Concurrency: Part II

The scheduledTaskCancellation() method at (13) illustrates how to cancel a submitted task by scheduling a…

The Fork/Join Framework – Concurrency: Part II

23.3 The Fork/Join Framework To harness the benefits of multicore architectures, the Fork/Join Framework in…

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…

Intrinsic Locking Revisited – Concurrency: Part II

Intrinsic Locking Revisited Intrinsic locking provides a blocking, lock-based, thread-safe solution for concurrent threads accessing…

Reentrant Lock 3 – Concurrency: Part II

Example 23.12 illustrates using a reentrant lock to implement a thread-safe counter. The class ReentrantLockCounter…