[Solved] Optimizing thread calls in Java [closed]
Use a loop and an ExecutorService. ExecutorService executor = Executors.newCachedThreadPool(); for (int i = 0; i < count; i++) { executor.execute(new TokenStarter()); } That should recreate your code, but is not optimal. You probably want to limit the amount of threads that run concurrently: ExecutorService executor = Executors.newFixedThreadPool(desiredParallelism); solved Optimizing thread calls in Java [closed]