📄 sleepcommand.java
字号:
public class SleepCommand implements Command
{
private Command wakeupCommand = null;
private ActiveObjectEngine engine = null;
private long sleepTime = 0;
private long startTime = 0;
private boolean started = false;
public SleepCommand(long milliseconds, ActiveObjectEngine e, Command wakeupCommand)
{
sleepTime = milliseconds;
engine = e;
this.wakeupCommand = wakeupCommand;
}
public void execute() throws Exception
{
long currentTime = System.currentTimeMillis();
if (!started)
{
started = true;
startTime = currentTime;
engine.addCommand(this);
}
else if ((currentTime - startTime) < sleepTime)
{
engine.addCommand(this);
}
else
{
engine.addCommand(wakeupCommand);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -