开篇词 (1讲)
代码篇 (2讲)
01 | 使用了并发工具类库,线程安全就高枕无忧了吗?
@Override
@GetMapping(value = "/{id}/")
public ResponseEntity getOne(@PathVariable Object id) {
try{
log.warn(Thread.currentThread().getName() + ":" + currentUser.get());
currentUser.set(id);
log.warn(Thread.currentThread().getName() + ":" + currentUser.get());
return responseEntity.success(service.getById((Serializable) id));
}finally {
currentUser.remove();
}
}
02 | 代码加锁:不要让“锁”事成为烦心事
本文深入探讨了并发编程中的线程安全问题,通过实例分析并发工具类库的使用,并不总能确保代码的线程安全性。文章进一步讲解了如何正确地在代码中实现加锁机制,避免因锁引发的复杂问题。
2640

被折叠的 条评论
为什么被折叠?



