Replace ThreadLocals by variables.
Synchronize cache update in Cached(Batch)DiffFunction.
no need for synchronized.