Andrew Gazelka
02/20/2019, 5:40 PMfun test1() {
println("1")
printId()
thread {
println("2")
printId()
throw IllegalStateException("an exception")
}.join()
println("3")
}
fun printId(){
println("Thread ID: $id")
}
val id get() = Thread.currentThread().id
and getting
1
Thread ID: 1
2
Thread ID: 11
Exception in thread "Thread-0" java.lang.IllegalStateException: an exception
at com.github.andrewgazelka.kotlintest.ThreadExceptionTestKt$test1$1.invoke(ThreadExceptionTest.kt:12)
at com.github.andrewgazelka.kotlintest.ThreadExceptionTestKt$test1$1.invoke(ThreadExceptionTest.kt)
at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
3
why Thread-0
?Systemkern
02/22/2019, 8:12 AMAndrew Gazelka
02/23/2019, 9:11 PM