Files
kotlin/libraries/stdlib/test/concurrent/ThreadTest.kt
2012-09-26 19:19:44 +02:00

31 lines
666 B
Kotlin

package concurrent
import kotlin.concurrent.*
import kotlin.test.*
import org.junit.Test as test
import java.util.concurrent.*
import java.util.concurrent.TimeUnit.*
class ThreadTest {
test fun scheduledTask() {
val pool = Executors.newFixedThreadPool(1)
val countDown = CountDownLatch(1)
pool {
countDown.countDown()
}
assertTrue(countDown.await(2, SECONDS), "Count down is executed")
}
test fun callableInvoke() {
val pool = Executors.newFixedThreadPool(1)
val future = pool<String> {
"Hello"
}
assertEquals("Hello", future.get(2, SECONDS))
}
}