From the course: Java EE: Concurrency and Multithreading
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
ExecutorService: invokeAny and invokeAll
From the course: Java EE: Concurrency and Multithreading
ExecutorService: invokeAny and invokeAll
- [Instructor] Okay so now that we've seen how to submit a task via the ExecutorService, let's take a look at a few other APIs. The first one is invokeAny and invokeAll. Now both of these methods help you submit a collection of tasks unlike in the previous demo where we submitted each task individually. And when you call the invokeAll method, it makes sure that it submits all the tasks, executes them and returns their output. And that output will be a list of futures this time because it's a collection of tasks okay? Now the invokeAny method is a little different. It is going to make sure that it submits all your tasks, however, it is going to return you the output of the first successful or the exceptional execution okay? So what we're going to do, we are going to go back to the project and we're going to make a very small example, where to understand how these methods work. So let's make a class and let's say, LoggingProcessor. Let this implement a callable. Let's say this returns a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Features of the Executor framework and thread pools4m 35s
-
(Locked)
Callables and futures2m 16s
-
(Locked)
Executor and ExecutorService3m 58s
-
(Locked)
ExecutorService overview3m 3s
-
(Locked)
Define UserDao and user beans6m 50s
-
(Locked)
Write the UserProcessor callable implementation5m 31s
-
(Locked)
Write a test class and run the application10m 48s
-
(Locked)
Different thread pools5m 20s
-
(Locked)
ExecutorService: invokeAny and invokeAll7m 18s
-
(Locked)
ExecutorService shutdown5m 18s
-
(Locked)
ScheduledExecutorService overview2m 7s
-
(Locked)
The schedule method5m 16s
-
(Locked)
scheduleAtFixedRate and scheduleWithFixedDelay6m 42s
-
(Locked)
ThreadFactory API2m 34s
-
(Locked)
Create a custom thread factory5m 26s
-
-
-
-