Cleanup concurrent

This commit is contained in:
Ilya Ryzhenkov
2014-09-12 15:50:30 +04:00
committed by Andrey Breslav
parent 3ab1901f06
commit c074b4317e
4 changed files with 59 additions and 67 deletions
+3 -11
View File
@@ -12,23 +12,15 @@ class TimerTest {
test fun scheduledTask() {
val counter = AtomicInteger(0)
val timer = Timer()
/*
TODO this generates a compiler error!
val task = timer.scheduleAtFixedRate(1000, 1000) {
val task = timer.scheduleAtFixedRate(1000, 100) {
val current = counter.incrementAndGet()
println("Timer fired at $current")
}
*/
val task = timerTask {
val current = counter.incrementAndGet()
println("Timer fired at $current")
}
timer.scheduleAtFixedRate(task, 1000, 1000)
Thread.sleep(5000)
Thread.sleep(1500)
task.cancel()
val value = counter.get()
assertTrue(value > 2, "current counter is $value")
assertTrue(value > 4, "current counter is $value")
}
}