Java / Java ThreadLocal
Generic ThreadLocal variables.
ThreadLocal is a generic class which helps eliminates the need of typecasting the value being returned by the get() method.
The below code shows the way to create a generic ThreadLocal variable.
Creating a generic ThreadLocal variable ensures type safety thus set() method accepts only String and get() method returns only String Object eliminating the need of manual typecasting.
More Related questions...