public class Road {
List<String> vehicle = new ArrayList<String>();
private String name = null;
public Road(String name){
this.name = name;
ExecutorService pool = Executors.newSingleThreadExecutor();//java5的线程
pool.execute(new Runnable(){ //创建线程
public void run(){
for(int i=1;i<1000;i++){
try {
Thread.sleep((new Random().nextInt(10) + 1) * 1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
vehicle.add(Road.this.name + "_" +i);
}
}
});
}
}
请问Road.this.name是外部类的成员变量变量吗,我认为应该是的,内部类可以访问外部类的局部变量吗 要是可以请问怎么访问? |