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 a test class and run the application
From the course: Java EE: Concurrency and Multithreading
Write a test class and run the application
- [Narrator] The next step is to test this code out. We've already written the user dao, we've created the user bean, and we've created the callable implementation. Now let's test this out. So, in a test class, the first thing that you have to do is get a collection of string values from that file. So let's come to the IDE, under the Tests folder, let's create a class. Let's call this TestExecutors, and let's grab the main method quickly. Okay, now we're going to write a separate method to read that file, and get a list of all those lines, okay? So, I'm going to say public static getUsersFromFile. The parameter to this will be a file name. And what is this going to return me? This is going to return me a list of string. Each line in the file is one string, and I'll make such a list of strings. Okay, now the file reading code is something that we've already coded in one of our previous demos, so I'm not going to write that code again. I'll pull it out from the AppThread.java class…
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
-
-
-
-