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?
posted 12 years ago
This kind of overlaps with your other post ... but just put them in any Collection type, eg list, map, set. Get them all started then iterate through and join.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi