子线程中的事务不能自动提交吗?

public void afterJFinalStart() {

UploadThread up = Duang.duang(UploadThread.class);

up.start();

}





public class UploadThread extends Thread {


public static LinkedBlockingQueue<UploadTask> queue = new LinkedBlockingQueue<UploadTask>();


@Override

public void run() {

while (true) {

try {

UploadTask task = queue.take();

byte[] buffer = task.getContent();

ProResources resources = ProResources.dao.findById(task.getId()); 

int type = resources.getType();

long size = resources.getBeforeSize();

resources.setUpdatetime(DateUtils.nowTime());

resources.setAfterSize(size);

resources.setState(2);

resources.update();

System.out.println("更新完毕");

} catch (Exception e) {

resources.setState(3);

resources.update();

System.out.println("更新完毕");

}

} catch (Exception e) {

e.printStackTrace();

}

}

}

}

能查询出来数据,能设置进去属性,到update就没任何反应了,也不报错,数据库记录也没有更新,sysout的内容也没有输出,但是循环又到下次循环去了。

评论区

热门反馈

扫码入社