O'Reilly logo
live online training icon Live Online training

Core Java Synchronizers

Douglas Schmidt

Attendees in this course will learn how to apply key Java synchronizer to develop more efficient concurrent programs that run scalably on multi-core processors using Java’s object-oriented and functional programming language features. Java provides an integrated set of interfaces & classes that collaborate to provide reusable synchronizers that support mutual exclusion and coordination of interacting threads. This training focuses on the structure and functionality of Java’s core synchronizers, such as ReentrantLock, ConditionObject, and Semaphore. This course assumes working knowledge of Java and presents many concrete examples of applying core Java synchronizers, all of which are available as open-source.

What you'll learn-and how you can apply it

  • Develop efficient concurrent programs using powerful Java object-oriented and functional programming language features and the Java ReentrantLock, ConditionObject, and Semaphore classes that can be applied to provide the foundation for concurrent processing on multi-core platforms.
  • Know where to find additional sources of information on how to successfully develop robust concurrent programs using core Java synchronizers.

This training course is for you because...

  • For software developers creating scalable apps on modern multi-core processors in Java.

Prerequisites

This training is intended for software developers who are familiar with:

  • General object-oriented design and programming concepts, such as encapsulation, abstraction, polymorphism, extensibility, and the Unified Modeling Language (UML),
  • Core object-oriented programming language features, such as classes, inheritance, dynamic binding, and generics, that are available in Java,
  • Core functional programming features, such as lambda expressions, method references, and functional interfaces, that are available in Java, and
  • Core functional programming features in Java are covered in another Live Training course titled Programming with Java Lambdas and Streams
  • How to download and install the Java JDK and JRE
  • How to download and install an IDE, such as IntelliJ, NetBeans, Eclipse, or Android Studio

Course Set-up

  • An installed copy of the Java JDK and JRE (Java 8 or 9 versions are preferred)
  • An installed copy of IntelliJ, NetBeans, Eclipse, or Android Studio

Recommended Preparation

About your instructor

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

Segment 0 Overview of the Course Length (5 minutes)

  • Instructor will explain the contents covered in this course and provide links to additional online resources.

Segment 1 Overview of the Java Memory Model Length (5 minutes)

  • Instructor will describe the Java memory model and explain how it defines the semantics of multi-threaded access to shared memory.

Segment 2 Overview of Java Synchronizers Length (5 minutes)

  • Instructor will describe how Java synchronizers are used to control the flow of cooperating threads based on their state to ensure interactions between threads obey certain properties.

Segment 3 Types of Java Synchronizers Length (10 minutes)

  • Instructor will describe the key types of Java synchronizers that support atomic operations, mutual exclusion, coordination, and barrier synchronization.

Segment 4 Synopsis of Java Synchronizer Classes Length (10 minutes)

  • Instructor will give a synopsis of key Java synchronizer classes, including ReentrantLock, ReentrantReadWriteLock, StampedLock, Semaphore, ConditionObject, CountDownLatch, CyclicBarrier, and Phaser.

Segment 5 Usage Considerations for Java Synchronizers Length (5 minutes)

  • Instructor will explain how to choose between various Java synchronizers based on an understanding of the tradeoffs between performance and productivity.

Segment 6 The Java ReentrantLock Class Length (40 minutes)

  • Instructor will describe the structure and functionality, key methods, example applications, and usage considerations of the Java ReentrantLock class, which defines mutual exclusion lock (mutex) that ensure only one thread can run in a block of code at a time.

Break (5 minutes)

Segment 7 The Java ConditionObject Class Length (50 minutes)

  • Instructor will describe the structure and functionality, key methods, example applications, and usage considerations of the Java ConditionObject class, which allows a thread to (repeatedly) suspend its execution until a condition is satisfied.

Break (5 minutes)

Segment 8 The Java Semaphore Class Length (45 minutes)

  • Instructor will describe the structure and functionality, key methods, example applications, and usage considerations of the Java Semaphore class, which can be atomically incremented & decremented to control access to a shared resource.