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 on, you’ll discover a whole range of recipes for almost everything, such as thread management, synchronization, executors, parallel and reactive streams, and much more.
By the end of the video, you will know 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 Publishing.
The executor uses one of its pooled threads or creates a new one to execute the tasks. It also decides the moment in which the task is executed.
With the Executor framework, you only have to implement your tasks and send them to the executor. The executor is responsible for the creation and execution of the threads that execute your tasks.
Java provides theThreadFactory interface to implement a Thread object factory. Some advanced utilities of the Java concurrency API, such as the Executor framework or the fork/join framework, use thread factories to create threads.
The Executor framework is a mechanism that allows you to separate thread creation and its execution. It's based on the Executor and ExecutorService interfaces and the ThreadPoolExecutor class that implements both these interfaces.
Scheduled thread pool is an extension of the basic thread pool of the Executor framework that allows you to schedule the execution of tasks to be executed after a period of time.
One of the most interesting features of Java 9 is the fork/join framework. It's an implementation of the Executor and ExecutorService interfaces that allows you to execute the Callable and Runnable tasks without managing the threads
Java 9 provides a special kind of executor in the fork/join framework. The fork/join framework implements the work-stealing algorithm that improves the overall performance.
In the Java Concurrency API, locks are declared in the Lock interface and implemented in some classes, for example, the ReentrantLock class
In this video, we will implement a data structure which is to be used in the producer / consumer problem; whose elements will be ordered by priority.
In this video, we will extend an atomic object and implement two operations that follow the mechanisms of the atomic objects to guarantee that all the operations are done in one step
Streams are based on the Stream interface and some related classes and interfaces included in the java.util.stream package. In this video, we will implement our own Spliterator interface and create a Stream interface to process its data
Java 9 has included three interfaces--Flow.Publisher, Flow.Subscriber, and Flow.Subscription--and a utility class, SubmissionPublisher, to allow us to implement reactive stream applications.
A critical section is a block of code that accesses a shared resource and can't be executed by more than one thread at the same time. This mechanism is implemented by the Lock interface and the ReentrantLock class.
One of the most complex and powerful functionalities offered by the Java Concurrency API is the ability to execute concurrent-phased tasks using the Phaser class. This mechanism is useful when we have some concurrent tasks divided into steps.
The Executor framework provides a mechanism that separates the implementation of tasks from thread creation and management to execute the tasks.
The Executor framework is designed to solve problems that can be broken down into smaller tasks using the fork() and join() operations. The main class that implements this behavior is ForkJoinPool.
A stream in Java is a sequence of elements that could be processed either parallelly or sequentially in a pipeline of declarative operations using lambda expressions.
A log system is a mechanism that allows you to write information to one or more destinations. In this video, we will use the classes provided by the java.util.logging package to add a log system to your concurrent application.
Static code analysis tools are a set of tools that analyze the source code of an application while looking for potential errors. The objective is to find errors or places that cause poor performance at an early stage, before they are executed in production.
MultithreadedTC is a Java library for testing concurrent applications. it includes an internal metronome. These testing threads are implemented as methods of a class.
JConsole is a monitoring tool that follows the JMX specification that allows you to get information about the execution of an application as the number of threads, memory use, or class loading. In this video, we will use this tool to monitor a simple concurrent application
Some classes of the java.util.concurrent package use atomic variables instead of synchronization. In this video, you will develop an example that shows how an atomic attribute provides better performance than synchronization.
Locks allow the definition of a critical section that only one thread can execute at a time. In this video, we will implement an example to see the difference in the performance of a task with a long operation inside the critical section and a task with a long operation outside the critical section.
The use of executors has a lot of advantages over direct utilization of threads. In this video, we will implement an example that shows how you can obtain better performance using an executor than creating the threads yourself.
Lazy initialization is a common programming technique that delays object creation until it is needed for the first time. In this video, we will implement an elegant solution to the lazy initialization problem
Java 7 provides a new kind of executor with the fork/join framework. This executor, implemented in the ForkJoinPool class, is designed for problems that can be split into smaller parts using the divide and conquer technique. For these kinds of problems, fork/join pools get better performance than classical executors.
Blocking operations are operations that block the execution of the current thread until an event occurs. Typical blocking operations are those that involve input or output operations with the console, a file, or network. The threads read a line from the console inside the critical section. This instruction makes the rest of the threads of the application will be blocked until the user introduces the line.
A Stream interface is a sequence of elements that can be filtered and transformed to get a final result sequentially or in parallel. In this video, we will process big data sets using streams.
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.