ThreadLocal explained

Today we are going to look into the ThreadLocal internals, its usage and all the related pitfalls.

ThreadLocal, among other Java advanced features like volatile variables or nested classes, is rarely used.

The main reason is its relative complexity and mostly the very few cases where ThreadLocal is really required.

Yet, if its underlying mechanism is well understood, ThreadLocal can be very handy in some situations. No wonder it is at the heart of some framework features, Spring
TransactionSynchronizationManager for example.
Read more of this post


Java, pass by value/reference or copy of value/reference ?

This basic question is in any Java 101 courses and the answer is quite obvious. But in fact things are a little bit trickier than they seem to be.
Read more of this post