What is the equivalent of setTimeOut() javascript to Android?

后端 未结 4 1473
被撕碎了的回忆
被撕碎了的回忆 2021-02-06 23:59

I need the equivalent code of setTimeOut(call function(),milliseconds); for android.

setTimeOut(call function(),milliseconds);
4条回答
  •  Happy的楠姐
    2021-02-07 00:50

    There is setTimeout() method in underscore-java library. I am the maintainer of the project.

    Code example:

    import com.github.underscore.lodash.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.

提交回复
热议问题