I need to add delay without using Thread.sleep() or a while loop doing nothing. The game im editing(Minecraft) clock runs on \"Ticks\" but they can fluctuate depending on yo
One of approaches is :
class Timer {
private static final ScheduledExecutorService scheduledThreadPoolExecutor = Executors.newScheduledThreadPool(10);
private static void doPause(int ms) {
try {
scheduledThreadPoolExecutor.schedule(() -> {
}, ms, TimeUnit.MILLISECONDS).get();
} catch (Exception e) {
throw new RuntimeException();
}
}
}
and then you can use Timer.doPause(50) where you need.