📄 clock.java
字号:
import org.jcsp.lang.CSProcess;
import org.jcsp.lang.ChannelOutput;
class Clock implements CSProcess {
// protected attributes
protected static final int seconds = 1000;
protected static final int period = 1*seconds;
protected ChannelOutput report;
// constructors
public Clock (ChannelOutput report) {
this.report = report;
}
// public methods
public void run () {
int tick = 0;
while (true) {
report.write (new ClockReport (tick));
sleep (period);
tick++;
}
}
// protected methods
protected void sleep (long t) {
try {
Thread.sleep (t);
} catch (InterruptedException e) {};
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -