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

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…

Contents