I was exploring the Thread local in Java. I could not understand as why do we need this class. I can achieve the same motive if I just simply pass a new object to each thread for execution as same thing happens if i use initialValue(). I simply return a new object for each thread in initialvalue().
But say i have two threads, ThreadOne: A and ThreadTwo B. Now I want them to have a copy of own of say SimpleDateFormat class. I can do this by warping the object of SimpleDateFormat in a ThreadLocal Class and then using initialValue() I can return new SimpleDateFormat("yyyyMMdd HHmm");. Same motive I can achieve by creating two new Objects of SimpleDateFormat and p[assing one each to ThreadOne : A. and ThreadTwo : B. How does ThreadLocal help me extra
Regards,