I have a few questions about Java multi-threading. I am currently learning different methods of multi-threading. My first question is, what happens to the thread after the code in it is done running? Do I need to Stop/Kill the thread? I am currently making a class for each thread and implementing Runnable in each class. I then start the thread in the main class using new ThreadClass();. In the constructor of the Thread class, I have it set to make a Thread named “second.” If I add new ThreadClass() twice in the main method, are both threads named “second”? Thanks.
I have a few questions about Java multi-threading. I am currently learning different methods
Share
The thread stops when it has nothing to do. If you have an ExecutorService, you have to use shutdown when you have finished with it.
You are making the code the same. This doesn’t mean the name of the thread has to be the same (and vice-versa)