RFR 8010182: Thread safety of Thread get/setName() (original) (raw)
Chris Hegarty chris.hegarty at oracle.com
Sat May 18 07:57:16 UTC 2013
- Previous message: hg: jdk8/tl/jdk: 8012261: update policytool to support java.net.HttpURLPermission
- Next message: RFR 8010182: Thread safety of Thread get/setName()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: hg: jdk8/tl/jdk: 8012261: update policytool to support java.net.HttpURLPermission
- Next message: RFR 8010182: Thread safety of Thread get/setName()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]