How can we count the time of process?

。_饼干妹妹 提交于 2019-12-01 16:52:18

GWT has its own implementation of Timer.

Here a really small example:

public void onModuleLoad() {
    final PopupPanel popUp = new PopupPanel();
    Label text = new Label("gone in a sec");
    popUp.setWidget(text);

    Timer timer = new Timer() {

        @Override
        public void run() {
            popUp.hide();
        }

    };

    popUp.center();
    timer.schedule(3000);
}

Try to use: java.util.Timer

And you can do something like this:

int seconds = 60;
Timer timer = new Timer();
timer.schedule(new YourScheduledTask(), seconds * 1000);

Exmaple: Use java.util.Timer to schedule a task to execute once 5 seconds have passed

You could use Thread.sleep(60000);

But be careful you have to chose the correct thread to pause. And exception handling also has to be added.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!