📄 clockthread.java
字号:
package utility;
import server.HandleASession;
import client.ClientPlayer;
import client.InfoPanel;
public class ClockThread extends Thread {
private int currentTime;
private int unit;
private boolean exit = false;
private InfoPanel info;
private ClientPlayer client;
private HandleASession session;
public ClockThread(int timeout, int unit, InfoPanel info,
ClientPlayer client) {
this.unit = unit;
this.info = info;
this.currentTime = timeout;
this.client = client;
}
public ClockThread(int timeout, int unit, HandleASession session)
{
this.unit = unit;
this.currentTime = timeout;
this.session = session;
}
public void run() {
try {
while (true) {
if (!this.exit) {
this.info.update(this.currentTime);
this.info.validate();
Thread.sleep(this.unit);
this.currentTime--;
if (this.currentTime < 0 ) {
this.exit = true;
if(this.client.isMyTurn())
this.client.timeOut();
}
}
}
}
catch (InterruptedException ie) {
ie.printStackTrace();
}
}
public int getCurrentTime() {
return this.currentTime;
}
public void setCurrentTime(int time) {
this.currentTime = time;
}
public void stopTimer() {
this.exit = true;
}
public void wakeup() {
this.exit = false;
}
public HandleASession getSession() {
return session;
}
public void setSession(HandleASession session) {
this.session = session;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -