I have a Thread and I need to set when it is listening or in standby, for that I've defined

```
public static enum ListenerState { STAND_BY, LISTENING }; 

```

and a method

```
public void setState(ListenerState state){
    this.state = state;
}

```

now, in the main loop I check the state in this way

```
@Override
public void run() {
    while (!Thread.interrupted()) {
        try {
            if (state==ListenerState.LISTENING){
               // do my job
            }
            else{
                Thread.sleep(300);
            }
        }
    }
}

```

Is this approach thread-safe ?