Statements about the code

Report a typo

Take a look at a class Worker. It extends the Thread class.

The class has one boolean field stopped and a function to set the field to true.

class Worker: Thread() {
    var stopped = false

    override fun run() {
        // do some work while stopped is false
    }

    fun stopIt() {
        this.stopped = true
    }
}

The function stopIt will be invoked by other threads like:

worker.stopIt()

Select all correct statements about the given code.

Select one or more options from the list
___

Create a free account to access the full topic