Java 9 Concurrency - High-Level Elements
0.0 (0 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
11 students enrolled
Wishlisted Wishlist

Please confirm that you want to add Java 9 Concurrency - High-Level Elements to your Wishlist.

Add to Wishlist

Java 9 Concurrency - High-Level Elements

Learn the Java Concurrency API with Thread Executors and the Fork/Join Frame work
0.0 (0 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
11 students enrolled
Created by Packt Publishing
Last updated 8/2017
Current price: $10 Original price: $125 Discount: 92% off
5 hours left at this price!
30-Day Money-Back Guarantee
  • 3 hours on-demand video
  • 1 Supplemental Resource
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
What Will I Learn?
  • Separate thread management from the rest of the application with the Executor framework
  • Solve problems using a parallelized version of the divide-and-conquer paradigm with the Fork/Join framework
  • Process massive data sets in an optimized way using streams and reactive streams
View Curriculum
  • Viewers should already be comfortable with general Java development practices, and a basic grasp of threads would be an advantage.

Writing concurrent and parallel programming applications is a crucial skill for any Java programmer. Java 9 comes with a host of fantastic features, including significant performance improvements and new APIs. This video will take you through all the new APIs, showing you how to build parallel and multi-threaded applications. The video covers all the elements of the Java Concurrency API, with essential recipes that will help you take advantage of the exciting new capabilities. You will learn how to use parallel and reactive streams to process massive data sets. Next, you will move on to create streams and use all their intermediate and terminal operations to process big collections of data in a parallel and functional way. Further, you’ll discover a whole range of recipes for almost everything, such as thread management, synchronization, executors, parallel and reactive streams, and many more. At the end of the video, you will learn how to obtain information about the status of some of the most useful components of the Java Concurrency API and how to test concurrent applications using different tools.

About the Author

Javier Fernández González is a software architect with almost 15 years experience in Java technologies. He has worked as a teacher, researcher, programmer, analyst, and writer, and he now works as an architect in all types of projects related to Java, especially J2EE. As a teacher has over 1,000 hours of training in basic Java, J2EE, and the Struts framework. As a researcher, he has worked in the field of information retrieval, developing applications for processing large amounts of data in Java, and has participated as a co-author in several journal articles and conference presentations. Recently, he worked on developing J2EE web applications for various clients from different sectors (public administration, insurance, healthcare, transportation, and so on). He has also worked as a software architect. He is the author of the books, Java 7 Concurrency Cookbook and Mastering Concurrency Programming with Java 8 by Packt.

Who is the target audience?
  • This course is for Java developers interested in further enhancing their knowledge of concurrent programming and multithreading, as well as discovering the new concurrency features of Java 8 and Java 9.
Students Who Viewed This Course Also Viewed
Curriculum For This Course
34 Lectures
Thread Executors
10 Lectures 55:15

This video gives overview of the entire course.

Preview 03:20

When we want to finish the execution of an executor, we use the shutdown() method. The executor waits for the completion of tasks that are either running or waiting for their execution. The ThreadPoolExecutor class provides a mechanism, which is called when a task is rejected.

Creating a Thread Executor and Controlling its Rejected Tasks

One of the advantages of the Executor framework is that it allows you to run concurrent tasks that return a result. The Java Concurrency API achieves this with Callable and Future interfaces.

Executing Tasks in an Executor that Returns a Result

A common problem in concurrent programming arises when you have various concurrent tasks available to solve a problem. You have various sort of algorithms. You can launch all of them and get the result of the first one that sorts the array, that is, the fastest sorting algorithm for a given array.

Running Multiple Tasks and Processing the First Result

When you want to wait for the finalization of a task, you can use the isDone() and awaitTermination() methods. These two methods have some drawbacks. The ThreadPoolExecutor class provides a method that allows you to send a list of tasks to the executor and wait for the finalization of all the tasks in the list.

Running Multiple Tasks and Processing all the Results

There are use cases when you are not interested in executing a task as soon as possible. You may want to execute a task after a period of time or do it periodically; the Executor framework provides the ScheduledExecutorService interface along with its implementation, namely, the ScheduledThreadPoolExecutor class.

Running a Task in an Executor After a Delay

The Executor framework provides the ThreadPoolExecutor class to execute concurrent tasks using a pool of threads that helps you avoid all thread creation operations.

Running a Task in an Executor Periodically

When you want to cancel a task that you send to the executor, you can use the cancel() method of Future, which allows you to make the cancelation operation.

Canceling a Task in an Executor

The Java API provides the FutureTask class as a cancelable asynchronous computation. It implements the Runnable and Future interfaces and provides the basic implementation of the Future interface.

Controlling a Task Finishing in an Executor

When you execute concurrent tasks using an executor, you will send Runnable or Callable tasks to the executor and get Future objects to control the method. For such situations, the Java Concurrency API provides the CompletionService class.

Separating the Launching of Tasks & Processing of their Results in an Executor
Fork/Join Framework
5 Lectures 35:07

The basic elements of the fork/join framework are creating a ForkJoinPool object to execute the tasks and creating a subclass of ForkJoinTask to be executed in the pool.

Preview 07:33

The fork/join framework provides the ability to execute tasks that return a result.

Joining the Results of the Tasks

In this video, you will learn how to use the asynchronous methods provided by the ForkJoinPool and CountedCompleter classes for the management of tasks.

Running Tasks Asynchronously

The behavior of the ForkJoinTask and ForkJoinPool classes is different. The program doesn't finish execution, and you won't see any information about the exception in the console. In this video, you will learn the techniques to get that information.

Throwing Exceptions in the Tasks

When you execute the ForkJoinTask objects in a ForkJoinPool class, you can cancel them before they start their execution. The ForkJoinTask class provides the cancel() Method.

Canceling a Task
Parallel and Reactive Streams
9 Lectures 47:55

In this video, you will learn how to create streams from different sources.

Preview 09:13

In this video, you will learn how to use the different versions of the reduce() method to generate a result from a stream of values.

Reducing the Elements of a Stream

In this video, we will learn how to execute collect operations in Java streams with the different versions of the collect() method and the auxiliary Collectors class.

Collecting the Elements of a Stream

In this video, you will learn to apply an action to all the elements of the stream. We will use three methods: two terminal operations, the forEach() and forEachOrdered(), and an intermediate operation, the peek() method.

Applying an Action to Every Element of a Stream

One of the most commons actions you will apply to a stream will be the filtering operation that selects the elements that continue with the processing. In this recipe, you will learn the different methods provided by the Stream class to select the elements of a stream.

Filtering the Elements of a Stream

Some of the intermediate operations that can be used with streams are those that allow you to transform the elements of the stream. In this video, you will learn to use the transforming intermediate operations.

Transforming the Elements of a Stream

Another typical operation you will want to perform with a Stream is sorting its elements. You can speed up the execution by deleting the ordering constraint.

Sorting the Elements of a Stream

One interesting option provided by the Stream class is the possibility to check whether the elements of the stream verify a  condition or not.

Verifying Conditions in the Elements of a Stream

Java 9 has included three interfaces: the Flow.Publisher, the Flow.Subscriber, and the Flow.Subscription, and a utility class, the
SubmissionPublisher class, to allow us to implement reactive stream applications.

Reactive Programming with Reactive Streams
Concurrent Collections
10 Lectures 39:16

A deque is a data structure similar to a queue, but you can add or remove elements from either the front (head) or back (tail) in a deque. In this video, you will learn how to use a non-blocking deque in a concurrent program.

Preview 04:09

The main difference between blocking deques and non-blocking deques is that blocking deques have methods to insert and delete elements that, if not done immediately. Java includes the LinkedBlockingDeque class that implements a blocking deque.

Using Blocking Thread-Safe Deques

Another important characteristic of PriorityBlockingQueue is that it's a blocking data structure. It has methods that, if unable to perform the operation immediately, will block the thread until they are able to do it.

Using Blocking Thread-Safe Queue Ordered by Priority

An interesting data structure provided by the Java API, which you can use in concurrent applications, is implemented in the DelayQueue class. In this program, we will learn to use the DelaydQueue class by storing in it some events with different activation dates.

Using Thread-Safe Lists with Delayed Elements

The Java API provides a class that implements ConcurrentSkipListMap, which is the interface that implements a non-blocking list with the behavior of the ConcurrentNavigableMap interface.

Using Thread-Safe Navigable Maps

A hash table is a data structure that allows you to map a key to a value. The Java API provides different hash table implementations through the Map and ConcurrentMap interfaces.

Using Thread-Safe HashMaps

Java introduced atomic variables. When a thread is performing an operation with an atomic variable and if other threads want to do an operation with the same variable, the implementation of the class includes a mechanism to check that the operation is done atomically.

Using Atomic Variables

Java introduced atomic arrays that provide atomic operations for arrays of integer or long numbers. In this video, you will learn to use the AtomicIntegerArray class to work with atomic arrays.

Using Atomic Arrays

In multithread applications, concurrent threads run in different CPUs or cores inside a CPU. To solve this problem, the Java language includes the volatile keyword.

Using the Volatile Keyword

Variable handles are a new feature of Java 9 that allow you to get a typed reference to a variable. You can use variable handles to obtain the same functionality without using any synchronization mechanism. A variable handle also allows you to get additional access modes to a variable.

Using Variable Handles
About the Instructor
Packt Publishing
3.9 Average rating
8,109 Reviews
58,369 Students
686 Courses
Tech Knowledge in Motion

Packt has been committed to developer learning since 2004. A lot has changed in software since then - but Packt has remained responsive to these changes, continuing to look forward at the trends and tools defining the way we work and live. And how to put them to work.

With an extensive library of content - more than 4000 books and video courses -Packt's mission is to help developers stay relevant in a rapidly changing world. From new web frameworks and programming languages, to cutting edge data analytics, and DevOps, Packt takes software professionals in every field to what's important to them now.

From skills that will help you to develop and future proof your career to immediate solutions to every day tech challenges, Packt is a go-to resource to make you a better, smarter developer.

Packt Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.