public class ArmyRunnable(){ volatile boolean keepRunning; public void run(){} ... }
外面定义keepRunning只是为了给keepRunning设置一个初始值,如果放在run方法里面,就会每次都给keepRunning赋值了。
外面的keepRunning是定义,里面的keepRunning是引用