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.
Create a custom thread factory
From the course: Java EE: Concurrency and Multithreading
Create a custom thread factory
- [Instructor] Now let's take a look at the ThreadFactory API demo. The steps are ready here, the first one is you to create a custom class, which implements the ThreadFactory interface. So let's head back to the IDE, and I want to create a totally different package for any kind of custom implementations that I want for my application. Okay, and under this package I'll create a class, and I will say CustomThreadFactory. Okay, and this should basically implement the ThreadFactory interface. Okay? Next is you to provide custom logic to decide the names or priorities. So the custom logic will be provided by the implementation of that abstract method. Okay. Let's get rid of the default implementation; we don't want that. And inside this, let's create an instance of Thread. And choose the construct to which sticks a Runnable argument so this task will be passed to it. And then, now is the chance to set your own name custom names, or maybe your own priorities, or even set the Daemon Thread…
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
-
-
-
-