+ 1
How to set an interval in Java (like you can do in JavaScript) (pls show example I still don't know)
Hello again. I would like to make a program that runs after a certain amount of time, but I have not been able to find the syntax for it on YouTube, here or on my java learning apps. How do I do this? (I want to have an interval in the way that Javasceipt set interval works but in Java) https://code.sololearn.com/ctZ01GndtgB3/?ref=app
4 Respuestas
+ 6
Cam UOR hi again, if you are looking for solution (for Android), than postdelayed will be easier one, otherwise you can go with timer class.
- both of this code will recall the task inside the run() method, for every 3 seconds.
: Android postDelayed Method
new Handler().postDelayed(
new Runnable()
{
public void run()
{
//Run your task here
}
},
1000 * 3);
: Java timer class
Timer timer = new Timer();
TimerTask task = new TimerTask() {
public void run()
{
//Run your task here
}
};
timer.schedule(task, 0L, 1000L * 3L);
0
Sorry I can't look at links cuz reasons
0
I added some code showing what I have but it no work...