Changes visibility problem

Report a typo

Take a look at the following class:

class MyClass {
    var intVal = 0
    var str = "empty"

    fun setFields(intVal: Int, str: String) {
        this.intVal = intVal
        this.str = str
    }
}

Suppose that we have an instance of the class. We'd like to call the function setFields from the thread with the following arguments:

instance.setFields(15, "string")

What values of the same instance may be seen by other threads after the thread ends executing the function setFields? It's guaranteed that other threads do not invoke setFields on the instance.

Select one or more options from the list
___

Create a free account to access the full topic