So I have some Java code that once it has ran through that part, I want it wait/delay for some amount of time. Here is the code I have:
Trajectory exampleTrajectory =
TrajectoryGenerator.generateTrajectory(trajectory);
TimeUnits.Second.sleep(10)
I have tried using TimeUnits.Second.sleep(10) but I keep getting an error saying that it cannot be resolved.
>Solution :
Instead of:
TimeUnits.Second.sleep(10)
It should be:
TimeUnit.SECONDS.sleep(10);
Complete working example:
import java.util.concurrent.*;
class Main {
public static void main(String[] args) {
System.out.println("a");
try {
TimeUnit.SECONDS.sleep(10); // 10 second delay
}
catch (InterruptedException e) {}
System.out.println("b");
}
}