您启动线程并立即等待完成(使用
join())。相反,您应该
join()在另一个for循环中进行for循环的外部操作,例如:
// start all threadsfor(int i=0; i<numberOfRaceCars; i++) { racecars[i].start();}// threads run... we could yield explicity to allow the other threads to execute// before we move on, all threads have to finishfor(int i=0; i<numberOfRaceCars; i++) { racecars[i].join(); // TODO Exception handling}// now we can printSystem.out.println("It's over!");


