0
如何在scala上实现count Timer
? 所有我想定时器,计数10秒前继续在我的方法。在scala上实现倒数计时器
所有我发现是这样的Stopwatch
:
包查看
class Stopwatch {
var start = System.currentTimeMillis()
def elapsed = System.currentTimeMillis() - start
def printElapsed(msg: String) = {
val delta = elapsed
new Thread(new Runnable {
def run = {
System.out.println(msg + " time ellapsed: " + delta + "ms")
}
}).start()
}
def restart = {
start = System.currentTimeMillis()
new Thread(new Runnable {
def run = {
System.out.println("------restart------")
}
}).start()
}
}
如果你想要的只是延迟,请查看Thread.sleep。 – Aivean