Execute an instruction every x seconds in a for loop of an arraylist using JAVA
问题 I think this question has already been answered but I can't find the right solution to my problem. I have a arraylist containing several "ball" objects. I want to browse this list to "shoot" each ball with x seconds between them. Here is the code I have, I tried with the Timertask , System.currentMillis() / nano but I can't find a solution that works. for(Ball ball: ballList) { // Browse the list ball.setMove(true); // Launch ball // Wait x seconds before sending new one // ... } Does anyone