我想构建一个应用程序,该应用程序使用多线程执行特定的实用程序。我想控制线程的数量。这是我想要做的:在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