How to call a method on specific time in java?

前端 未结 9 1873
Happy的楠姐
Happy的楠姐 2020-11-27 04:43

Is it possible to call a method in java at specific time? For example of I have a piece of code like this:

class Test{

    public static void main(String ar         


        
9条回答
  •  臣服心动
    2020-11-27 05:14

    Simple demo of java.util.Timer

    Timer t=new Timer();
    t.schedule(new TimerTask() {
        public void run() {
            foo();
        }
    }, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2012-07-06 13:40:20"));
    

提交回复
热议问题