package itcast.interview.traffic;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Road {
private List<String> vehicles = new ArrayList<String>();
private String name=null;
public Road(String name){
this.name = name;
ExecutorService pool= Executors.newSingleThreadExecutor();
pool.execute(new Runnable(){
public void run() {
for(int i = 1;i < 1000;i++)
Thread.sleep(1000);
vehicles.add(Road.this.name + "_" + i);
}
});
}
}
i有什么问题?为什么会这样。
|
|