How can I add x number of threads. For example if I want 5 threads to run, then I change my mind and want 10. Or for example I put 10 in a textbox and it will run 10 threads.
For example I usually have to do this to run 10 threads:
Thread t1 = new Thread (run);
Thread t2 = new Thread (run);
Thread t3 = new Thread (run);
Thread t4 = new Thread (run);
Thread t5 = new Thread (run);
Thread t6 = new Thread (run);
Thread t7 = new Thread (run);
Thread t8 = new Thread (run);
Thread t9 = new Thread (run);
Thread t10 = new Thread (run);
then
t1.start, t2.start, etc
Can I use a for loop somehow? Are is there and easier way of running X number of threads?