Visibility problem

Report a typo

Take a look at the following class:

class MyClass {
    private int intVal = 0;
    private String str = "empty";

    public void setFields(int intVal, String str) {
        this.intVal = intVal;
        this.str = str;
    } 

    public int getIntVal() {
        return intVal;
    }

    public String getStr() {
        return str;
    }
}

Suppose that we have an instance of the class. We'd like to call the method 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 method setFields? It's guaranteed that other threads do not invoke setFields of the instance.

Select one or more options from the list
___

Create a free account to access the full topic