So I have a thread and in that thread I declared a boolean like so:

```
volatile boolean stopThread = false;

```

Then in my thread look something like this:

```
public void run() {

    while (!stopThread) {

        while (i < list.size()) {
            System.out.println(list.get(i));
        }

    }

}

```

The threads are started like so:

```
t1 = new CheckThread();
t2 = new CheckThread();

```

Every thing works fine but I'd like to allow the user to stop the thread so I created a button and added the following two lines:

```
t1.stopThread = true;
t2.stopThread = true;

```

But when I click the button the thread still runs. I also tried the following

```
CheckThread.stopThread = true;

```

But that doesn't work either. **Why are my threads not stopping?**

EDIT: 

I start my thread like so. I have a class and outside any methods I have these two variables 

```
CheckThread t1;
CheckThread t2;

```

When the button is clicked I then do the following

```
t1 = new CheckThread();
t2 = new CheckThread();

t1.start();
t2.start();

```

I know the thread is running because I have a print statement in the thread.