Advanced Java: Threads and Concurrency
2h 51mAdvanced2024-04-17
Authors

Buddhini Samarakkody
Java Engineer, Author, Instructor
Course details
Are you looking to boost your Java skills? In this course, join instructor and Java expert Buddhini Samarakkody as she provides an overview of Java threads and the new concurrent programming model. Buddhini covers topics in synchronization such as Java thread memory access and associated problems such as race condition and data race. Explore the purpose of synchronization and how to use it, before turning to asynchronous programming with Future and CompletableFuture. Buddhini shows you how to use executors, the fork/join framework and its core classes, concurrent data structures, Project Loom, and virtual threads. Along the way, be sure to test out your new skills in the exercise challenges at the end of each section.
Skills covered
Software Design PatternsJavaProgramming FoundationsOracleLearningProgramming LanguagesSoftware Development
Concepts
Introduction
- Exploring advanced topics in Java threads
- What you should know
- Exercise files
Synchronization
- Memory access in Java threads and its problems
- Memory inconsistency - Data race
- Thread interference - Race condition
- Synchronization - Purpose and use
- Implementing synchronization
- Challenge - Inventory manager
- Solution - Inventory manager
Asynchronous Programming
- The need for non-blocking operations
- Future
- CompletableFuture
- Implementing CompletableFuture
- Challenge - Asynchronous computations
- Solution - Asynchronous computations
Executors
- Managing thread execution - Thread pools and executors
- ExecutorService
- Implementing an executor - ExecutorService in action
- Executing tasks periodically with ScheduledExecutorService
- Challenge - Number magic and voting simulator
- Solution - Number magic and voting simulator
Fork Join Framework
- Thread execution and the fork join framework
- Worker threads and work stealing
- The core classes of the fork join framework
- Using the fork join framework
- Challenge - Multiples calculator
- Solution - Multiples calculator
Concurrent Data Structures
- Thread safety in collections
- The need for concurrent collections
- Using concurrent collections
- Synchronized versus concurrent collections
Introduction to Project Loom
- The need for a new concurrent programming model
- Project Loom and virtual threads
- Platform threads versus virtual threads
Virtual Threads in Action
- Ways to create virtual threads
- Comparing performance - Platform versus virtual threads
- Benefits of using virtual threads
- Things to keep in mind when using virtual threads
Conclusion
- Next steps