Is the thread interrupted?

Report a typo

What is the output of this code snippet?

fun main() {
    val thread = thread(start = false, block = {
        if (!interrupted()) {
            println(interrupted())
        } else {
            while (true) {
                if (!interrupted()) {
                    println(interrupted())
                    break
                }
            }
        }
    })
    thread.start()
    thread.interrupt()
}

fun thread(
    start: Boolean,
    block: () -> Unit
): Thread {
    val thread = object : Thread() {
        override fun run() {
            block()
        }
    }
    return thread
}
Enter a short text
___

Create a free account to access the full topic