Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java equivalent of setInterval in javascript

Tags:

java

timing

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

How can I achieve that in Java?

like image 843
hasen Avatar asked Mar 16 '09 22:03

hasen


People also ask

What is setInterval in Java?

setInterval()function that repeats itself in every n milliseconds.

What can I use instead of setInterval?

Nested setTimeout calls are a more flexible alternative to setInterval , allowing us to set the time between executions more precisely. Zero delay scheduling with setTimeout(func, 0) (the same as setTimeout(func) ) is used to schedule the call “as soon as possible, but after the current script is complete”.

Is it good to use setInterval in JavaScript?

In order to understand why setInterval is evil we need to keep in mind a fact that javascript is essentially single threaded, meaning it will not perform more than one operation at a time.

What is setInterval and clearInterval in JavaScript?

The clearInterval() function in javascript clears the interval which has been set by setInterval() function before that. setInterval() function takes two parameters. First a function to be executed and second after how much time (in ms). setInterval() executes the passed function for the given time interval.


1 Answers

You might want to take a look at Timer.

like image 87
Bombe Avatar answered Oct 04 '22 03:10

Bombe