Asynchronous Programming in Java
Java SE 17 comes with its own asynchronous programming model. This course shows you how you can leverage this API to setup asynchronous systems, triggering tasks on the completion of other tasks, and how you report errors or recover from them.
What you'll learn
Asynchronous programming is the universal pattern to create efficient, safe, and high-throughput applications. Starting with Java SE 8, Java has its own API: CompletionStage, to create asynchronous data processing pipelines. In this course, Asynchronous Programming in Java you will lean how to create asynchronous tasks based on the three models this API provides: Runnable, Consumers, and Functions. First, you will see how you can chain these tasks to trigger them on the outcome of other tasks. Then, you will explore what are the threads that are executing your tasks in the default configuration of the API, and how you can control them to balance your application, giving the right number of threads to the right number of tasks. Next, you will discover how you can have certain tasks to run in specific thread, for instance in the case that you need to update a graphical component, the API provides several mechanisms to deal with exceptions. Finally, you will learn how does the API processes exceptions, how you can log them and how you can recover from them if your application permits it. When you are finished with this course, you will be able to write your own asynchronous data processing pipelines, and will have hints on how you can set them up to get better performance.
Table of contents
- Introducing the Module and Its Agenda 1m
- Checking Your Java Version 1m
- Improving the Throughput of Applications with Asynchronous Code 2m
- Who Are You and What Do You Need to Know? 1m
- Agenda of the Course 1m
- Executing Your Code in a Synchronous Way 1m
- Writing Non-concurrent Asynchronous Code 2m
- Avoid Blocking Your Long Running Tasks 2m
- Using Concurrency to Write Asynchronous Code 1m
- Launching a Task Using an Executor Service 1m
- Live Demo: Launching Several Tasks Synchronously 5m
- Live Demo: Improving the Throughput with an Executor Service 4m
- Live Demo: Using the CompletionStage API to Run Asynchronously 4m
- Module Wrap up 1m
- Introducing the Module and Its Agenda 1m
- Avoiding the Blocking of Your Application Threads 2m
- Introducing CompletionStage and CompletableFuture 1m
- Sending Asynchronously the Result of a Task to a Function 2m
- Designing an Efficient Asynchronous Processing Pipeline 2m
- Live Demo: Writing and Launching a First Processing Pipeline 8m
- Module Wrap Up 1m
- Introducing the Module and Its Agenda 1m
- Getting a Result Faster with the AnyOf Factory Method 3m
- Launching Several Tasks in Parallel with the AllOf Factory Method 1m
- Analyzing the CompletableFuture Returned by a Call to AllOf 2m
- Composing Long Running Tasks to Avoid Blocking 3m
- Live Demo: Finding the Best Elements of a Collection with AllOf 5m
- Live Demo: Getting a Result Faster with the AnyOf Factory Method 5m
- Live Demo: Composing Quotation and Weather Fetching 7m
- Module Wrap Up 2m