Skip to content →

每隔一定时间间隔查询是否有新消息

/**
 * 查询信息
 */
public void checkMessage(){
    TimerTask tt = new TimerTask() {
        public void run() {
            String unreadMsgNo = new CheckMessage().getUnreadMsgNo
                                    (URL, USER,
PASSWORD);
            if(unreadMsgNo.equals("0")){
                jLabelMsgTip.setText("您没有新信息!");
            } else{
                jLabelMsgTip.setText("您有" + unreadMsgNo + "条新信息!");
            }
        }
    };
    Timer t = new Timer();
    t.schedule(tt, 0, (long)1000*15);//每隔15秒执行一次
}

Published in CrazyBus

Comments

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.