Java equivalent of setInterval in javascript

后端 未结 4 852
独厮守ぢ
独厮守ぢ 2021-01-17 10:27

Basically I want a function to be called every say, 10 milliseconds.

How can I achieve that in Java?

相关标签:
4条回答
  • 2021-01-17 10:39

    You could also use a ScheduleExecutorService.

    0 讨论(0)
  • 2021-01-17 10:49

    You might want to take a look at Timer.

    0 讨论(0)
  • 2021-01-17 10:57

    I would say you would create a thread and in the thread loop add a System.sleep(10) to make the thread "sleep" for 10 ms before continuing.

    0 讨论(0)
  • 2021-01-17 11:05

    Check out java.util.Timer

    http://java.sun.com/javase/6/docs/api/java/util/Timer.html

    0 讨论(0)
提交回复
热议问题