How much is read from ThreadLocal
variable slower than from regular field?
More concretely is simple object creation faster or slower than access to ThreadLocal
variable?
I assume that it is fast enough so that having ThreadLocal<MessageDigest>
instance is much faster then creating instance of MessageDigest
every time. But does that also apply for byte[10] or byte[1000] for example?
Edit: Question is what is really going on when calling ThreadLocal
's get? If that is just a field, like any other, then answer would be "it's always fastest", right?