62,634
社区成员




public class HotelDetailThread implements Callable {
private static final Logger log = Logger.getLogger(HotelDetailThread.class);
private HotelDao hotelDao;
private List listHotelId;
private String index;
public HotelDetailThread(List listHotelId, String index,HotelDao hotelDao) {
this.listHotelId = listHotelId;
this.index = index;
this.hotelDao = hotelDao;
}
public Object call() throws Exception {
for (int i = 0; i < listHotelId.size(); i++) {
HotelEntity hotelId = (HotelEntity) listHotelId.get(i);
hotelDao.modifyHotelEntity(hotelId); // 执行更新操作
}
return "";
}
}
ExecutorService pool = Executors.newCachedThreadPool();
for (int i = 1; i <= maxPage; i++) {
PageListBean bean = new PageListBean();
bean.setCurrentPage(i);
List pagerList = bean.getPaper(listStr, pageSize);
Callable c = new HotelDetailThread(pagerList, i+"",hotelDao);
pool.submit(c);
}
pool.shutdown();