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 method to set the field to true.

class Worker extends Thread {

    private boolean stopped = false;

    @Override
    public void run() {
        // do some work while stopped is false
    }

    public void stopIt() {
        this.stopped = true;
    }
}

The method 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