I am pretty new to Java and the project I have requires a new thread to be created every time the user presses a button. I've worked with the MVC and Swing but I am trying to find a way to create however many threads the user needs. I reviewed some information and was trying to use an arrayList to just collect all the threads. However I am having some problems with this:
private ThreadLibrary thread_lib = new ThreadLibrary();
public TestArray(int val) {
for (int i=0; i < val; i++) {
thread_lib.addThread( new Thread(new runThread()).start() );
}
}
Since the new operator doesn't return anything it won't add anything to the arrayList. Any ideas or a better data structure to use? Thanks