Well, I've come to my wit's end: I would say it is 2 threads here. Why should I have three I don't know.
public class ParallelProgramming {
public static void main(String[] args) {
Thrd firstThread = new Thrd("FirstThread.txt");
firstThread.start();
Thrd secondThread = new Thrd("SecondThread.txt");
secondThread.start();
} // main
} // class
public class Thrd extends Thread {
String file;
public Thrd(String file) {
this.file = file;
}
@Override
public void run(){
<read the file line by line>
}
}
Because the two threads are started by the main thread which is created when you start the application (in some cases, it's called UI thread too).
This thread runs main
method.
In every java application there is a main thread. It executes the program. It can create new threads as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.