📄 updatethread.java
字号:
package com.demo2.web.servlet;
import com.demo2.persist.ShowTimeDao;
import com.demo2.persist.ShowTimeDaoImpl;
/**
* 线程类 把更新方法放入线程中,只有1秒时间到的时候才执行更新操作
* @author bluedot
*
*/
public class UpdateThread extends Thread {
public void run(){
ShowTimeDao showTimeDao= new ShowTimeDaoImpl();
String time = showTimeDao.showTime().get(0).getSecond();
int showtime = Integer.parseInt(time);
while(showtime>=0){
showTimeDao.updateTime();
try {
sleep(1000); //每次对数据库操作,就要暂停一秒
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
time = showTimeDao.showTime().get(0).getSecond();
showtime = Integer.parseInt(time);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -