Java Business Development Common Errors 100 cases

The opening words (1 lecture)

Code articles (2 speaking)

 

01 | concurrent use of library tools, thread-safe sit back and relax it?

@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 | Code lock: Do not let the "lock" to become something bothering

 

Published 105 original articles · won praise 33 · views 30000 +

Guess you like

Origin blog.csdn.net/github_38596081/article/details/104784308