problem description
basic usage of ThreadLocal
the environmental background of the problems and what methods you have tried
my brother has a business scenario where, after executing the basic logic, the information of the order is stored in map and then pushed to another platform by http. In
map, there are two fields whose information is the url address and the other party"s interface address (among other information). But in the actual push process, these two fields are only used inside the method and are not included in the transmitted json. I removed it from map by first put and then remove, and then the leader suggested using ThreadLocal to ensure low intrusiveness of the code, but I didn"t see how to actually store multiple variables to use ThreadLocal
related codes
/ / Please paste the code text below (do not replace the code with pictures)
String a_key = data.get("a_key").toString();
String b_key = data.get("b_key").toString();
String c_url = data.get("c_url").toString();
data.remove("a_key");
data.remove("b_key");
data.remove("c_url");
what result do you expect? What is the error message actually seen?
use ThreadLocal to store multiple variables. Please analyze it
.