How can I set while repeat count per second?

Matrix4290 :

I use a while loop to repeat my codes in my program. I want to repeat a code 1000 times per second. How can I do this?

SDJ :

For the fixed-delay execution of some code, it might be a better approach to use a timer object, such as java.util.Timer or javax.swing.Timer, or even AnimationTimer, depending on what you're trying to accomplish. This being said, it's not possible to guarantee a frequency and a frequency of 1000/s (or period of 1ms) is quite fast, and java.util.Timer and javax.swing.Timer won't be able to keep up.

See also:

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=140048&siteId=1