RFR 8010182: Thread safety of Thread get/setName()
david.holmes at oracle.com
Wed May 22 04:17:18 UTC 2013
Still okay with me.
On 22/05/2013 1:58 AM, Chris Hegarty wrote:
> On 05/21/2013 06:07 AM, Mike Duigou wrote:
>> Looks good.
>> Since the char array is never modified it could use the String(char,
>> boolean) constructor. This has advantages for cases such as logging
>> which may read the thread name very many times.
> Thanks Mike, this would be a nice improvement.
> Final webrev:
>> On May 18 2013, at 00:57 , Chris Hegarty wrote:
>>> Thread getName and setName are not thread-safe. The "expected" usage
>>> is to set a name before starting the thread and only read it thereafter.
>>> It is desirable to support the setting of thread name dynamically,
>>> mainly for monitoring/management/debugging. The typical scenario is
>>> the single-writer, multiple-reader case. So, making name volatile is
>>> sufficient. However, setName also sets the native thread name. This
>>> is currently restricted to the current thread, since there could be a
>>> race if the thread is terminating. Making setName synchronized would
>>> eliminate that race, and allow for the native thread name to be set
>>> from other threads.
>>> This issue came up on c-i a while back .
More information about the core-libs-dev