I have a "for" loop and I need to add a one second slip for each loop traversed
for (int i = 0 ; i <= 10000; i++) {
//Función o algo que haga que se pare la aplicación en un segundo
}
I have a "for" loop and I need to add a one second slip for each loop traversed
for (int i = 0 ; i <= 10000; i++) {
//Función o algo que haga que se pare la aplicación en un segundo
}
Something like
Thread.sleep(1000);
?I think it is better to include
try
The
Thread.sleep()
is the base tool, but you can also consider using a rate limiter like the one in the GuavaRateLimiter
library , which is just as easy to use but solves a lot more problems. For example, with it it is easy to limit the speed of an application with multiple execution threads.RateLimiter