RFR (S): CR 8005926: (thread) Merge ThreadLocalRandom state into java.lang.Thread

Doug Lea dl at cs.oswego.edu
Mon Jan 14 23:55:50 UTC 2013

On 01/14/13 17:58, Chris Hegarty wrote:

>> I'm not sure what we are saving here. Since new TLR is a singleton, we
>> save ~64 bytes per classloader. Worth messing with advanced
>> serialization mechanics? Probably not. I'll publish a revised webrev soon.
> serialPersistentFields is really quite simple, and will help avoid any potential issues like this in the future. I can help implement this on top of your patch if you like.

Thanks to Alan and Aleksey for noticing this and to Chris for
offering some serialPersistentFields incantations!

(The only way to serialize a TLR represents a strange abuse to
begin with. You'd need to save the result of
ThreadLocalRandom.current() in a field of a serialized object.
Which would be a terrible idea ...)


More information about the core-libs-dev mailing list