How can i start multiple threads ( number of threads to start is not defined)? For instance Thread t1 = new Thread("One"); Thread t2 = new Thread("Two"); t1.start(); t2.start(); t1.join(); t2.join();
In this case the main thread will wait for both t1 & t2 to exit the run method. Here i can code the way given above coz it is know that there are 2 threads. But in case the number of threads to be started is dynamic, how do i go about that?