You are dealing with the class Worker that extends Thread. The class overrides the function run to do something useful.
class Worker : Thread() {
override fun run() {
try {
sleep(1000L)
} catch (e: InterruptedException) {
throw RuntimeException("You need to wait longer!", e)
}
val currentId = currentThread().id
if (currentId == mainThreadId) {
throw RuntimeException("You must start a new thread!")
}
while (true) {
if (isInterrupted) {
println("Interrupted")
break
}
}
}
}
You need to start an instance of this class in a new thread, wait for it a little (2000-3000 milliseconds), and interrupt this new thread.
If you do not interrupt the thread after starting, something bad will happen.