发布网友 发布时间:2022-04-26 09:31
共2个回答
热心网友 时间:2022-06-26 20:04
ApplicationContext context=new FileSystemXmlApplicationContext("/WebRoot/WEB-INF/applicationContext.xml");
PetInfoService pis=(PetInfoServiceImpl)context.getBean("piss");
private Thread t;
private int petId;
public UdpateThread(){
}
public UdpateThread(int petId)
{
this.petId=petId;
}
public void run() {
System.out.println("子线程开始了");
for(int i=0;i<5;i++){
PetInfoBean pib=pis.getMyPet(petId);
int bread=pib.getBread();
int clean=pib.getClean();
int exp=pib.getPetExp();
System.out.println("饥饿"+bread);
System.out.println("清洁"+clean);
System.out.println("成长"+exp);
pib.setBread(bread-10);
pib.setClean(clean-10);
pib.setPetExp(exp+50);
pis.edit(pib);
热心网友 时间:2022-06-26 20:04
亲,你去关注微信开发公众号有教程,酷盈