我想構建一個應用程序,該應用程序使用多線程執行特定的實用程序。我想控制線程的數量。這是我想要做的:在for循環中執行一定數量的線程
//initialize the number of threads to be 10
for(int i = 0; i < BIG_VALUE; i++) {
RunnableObject rb = new RunnableObject(i);
rb.run();
//the for loop should run for 10 loops. When one of the threads finish its job
//the for loop continues and runs another thread. The amount of threads should
//always be 10
}
我該怎麼在Java中這樣做?
你找'ExecutorService'? – TheLostMind