java - running multiple threads simultaneously -


help me please. run threads array in 1 time

public class main {     public static void main(string[] args) {         string [] folders = (new counter()).readfile();         thread[] threads = new thread[folders.length];         (int = 0; < folders.length; i++) {             threads[i] = new thread(new mythread(folders[i]));         }         startthreads(threads);     }      private static void startthreads(thread[] threads) {         (thread t : threads)             t.start();     } } 

other executors,but in case have n threader, wait each other. http://joxi.ru/b6aqvp3jtjbmfbw41ma

 string [] folders = (new counter()).readfile();     thread[] threads = new thread[folders.length];     int size= folders.length;      (int = 0; < folders.length; i++) {         threads[i] = new thread(new mythread(folders[i]));     }     executorservice executor = executors.newfixedthreadpool(folders.length);     (int = 0; < size; i++) {         runnable worker = new mythread(folders[i]);         executor.execute(worker);     }     executor.shutdown();     while (!executor.isterminated()) {     }     system.out.println("finished threads"); 


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -