public class Testphore implements Runnable {
private int id;
Testphore(int id){
this.id=id;
}
public void run() {
try {
System.out.println(this.id+"html写在这里.....");
} catch (Exception e) {
e.printStackTrace();
}
}
}
public class TestExecutor {
public static void main(String[] args)throws Exception{
ExecutorService es = Executors.newCachedThreadPool();
for(int i=1;i<5;i++){
es.execute(new Testphore(i));
}
es.shutdown();
}
}
shutdown,执行后不再接收新任务,如果里面有任务,就执行完