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.

ManagedThreadFactory with ThreadPoolExecutor

ManagedThreadFactory with ThreadPoolExecutor

From the course: Java EE: Concurrency and Multithreading

ManagedThreadFactory with ThreadPoolExecutor

- [Narrator] Now let's see how to use the ManagedThreadFactory with the ThreadPoolExecutor and that will help to you return an ExecutorService of the Java Standard Edition. Let's see how to do that. Let's get to the IDE and what I'm gonna do is in the Rest class itself on line number 40, I'm going to write a method. That method is public. It returns an ExecutorService. Now please understand that this is the ExecutorService of the java.util.concurrent package, so I'm trying to take the reference of the Standard Edition concurrency API. This is a little different because all this while we have been only dealing with Enterprise concurrency resources but we'll see how to use ManagedThreadFactory and then get an ExecutorService. So let's see how to do that. Okay so this is going to return you an ExecutorService and let's say, I'm going to say, getApplicationPool. And inside that I'll say, ExecutorService take a reference for it, and I'm going to say new ThreadPoolExecutor. That's the API…

Contents