RFR 8010182: Thread safety of Thread get/setName()
David Holmes
david.holmes at oracle.com
Tue May 21 04:36:52 UTC 2013
No surprise it is a thumbs up from me :)
Thanks,
David
On 18/05/2013 5:57 PM, 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 [1].
>
> http://cr.openjdk.java.net/~chegar/8010182/webrev.00/webrev/
>
> -Chris.
>
> [1]
> http://cs.oswego.edu/pipermail/concurrency-interest/2013-March/010935.html
More information about the core-libs-dev
mailing list