The problem with the previous code was that it created a ThreadLocal and then did a get in the constructing thread. That means that only one RandomFunction was ever created. All threads then use that one object, causing enormous cache line ping-ponging between cores and sockets.
The problem with the previous code was that it created a ThreadLocal and then did a get in the constructing thread. That means that only one RandomFunction was ever created. All threads then use that one object, causing enormous cache line ping-ponging between cores and sockets.