I need to implement a function to run after 60 seconds of clicking a button. Please help, I used the Timer class, but I think that that is not the best way.
There is setTimeout()
method in underscore-java library.
Code example:
import com.github.underscore.U;
import com.github.underscore.Function;
public class Main {
public static void main(String[] args) {
final Integer[] counter = new Integer[] {0};
Function incr = new Function() { public Void apply() {
counter[0]++; return null; } };
U.setTimeout(incr, 100);
}
}
The function will be started in 100ms with a new thread.