2020
09-27
09-27
Java单线程ThreadLocal串值问题解决方案
ThreadLocalThreadLocal适用于变量在线程间隔离,而在方法或类间共享的场景。代码@RestControllerpublicclassThreadLocalController{privatestaticfinalThreadLocal<String>currentUid=ThreadLocal.withInitial(()->null);@GetMapping("bad")publicMapdoBad(@RequestParam("uid")Stringuid){Stringbefore=currentUid.get();currentUid.set(uid);Stringafter=currentUid.get();Mapre...
继续阅读 >