Home > Back-end >  Localthread calls to get to the second is null
Localthread calls to get to the second is null

Time:01-11

A static property of a class, use threadlocal definition, using the static assignment,
 public class Variable {
Public static ThreadLocal The username=new ThreadLocal (a);

The static {
Variable. The username. Set (" aaa ");
}
}


Code to run on tomcat, when after the get request to get right the first time, get a second request to the is null, what reason is this excuse me?
My demand is each request the static property has an independent life cycle, which is the attribute in this request is global Shared, after the request is released, how to implement?
  • Related