2
synchronized 加锁失败
source link: https://www.oschina.net/question/2883519_2323807
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
synchronized 加锁失败
//Controller.class public static final Object lock = new Object(); String taskNo; synchronized (lock) { taskNo = this.taskOrderManager.getTask(loginUser, getTask); }
//TaskOrderManager.class public String getTask(LoginUser loginUser, GetTask getTask)
在Controller层调用的时候加锁未生效,在实际调用的时候还是会有多个线程获取到相同的数据。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK