What is the output of this snippet?
import java.lang.Thread.sleep
fun main() {
val thread = thread(start = false, block = {
while (Thread.currentThread().isInterrupted) {
try {
sleep(2000)
} catch (e: InterruptedException) {
Thread.currentThread().interrupt()
}
}
})
thread.start()
thread.interrupt()
println(Thread.currentThread().isInterrupted)
}
fun thread(
start: Boolean,
block: () -> Unit
): Thread {
val thread = object : Thread() {
override fun run() {
block()
}
}
return thread
}