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.
Write the UserProcessor callable implementation
From the course: Java EE: Concurrency and Multithreading
Write the UserProcessor callable implementation
- [Instructor] Now the next step is to define a class UserProcessor which will implement the callable or runnable. So the job of the thread now, right, that's the big step that we have to do. We have to create this class UserProcessor, which will implement either of the interfaces, callable or runnable, and the job of this task will be to process every user record, and call the dao to insert the record in the database. So, let's go to the IDE, and let's create a class and the runnables folder. Let's call it UserProcessor. Now the naming convention could be of your choice, you can either call it UserProcessor, or UserTask, or UserRunnable, any which way, so let's click on Finish, and let's make this implement the callable interface. And let's return a value of the integer type. So in the previous demo, we had returned the number of rows that got inserted into the database, we'll return that same integer back from the processor as well, OK? Now what we need to do in this class, we…
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
-
-
-
-