8010182: Thread safety of Thread get/setName()
Reviewed-by: dholmes, alanb, mduigou
This commit is contained in:
parent
eb6c8c5bc8
commit
64b3efd73b
@ -145,7 +145,7 @@ class Thread implements Runnable {
|
||||
registerNatives();
|
||||
}
|
||||
|
||||
private char name[];
|
||||
private volatile char name[];
|
||||
private int priority;
|
||||
private Thread threadQ;
|
||||
private long eetop;
|
||||
@ -1135,7 +1135,7 @@ class Thread implements Runnable {
|
||||
* @see #getName
|
||||
* @see #checkAccess()
|
||||
*/
|
||||
public final void setName(String name) {
|
||||
public final synchronized void setName(String name) {
|
||||
checkAccess();
|
||||
this.name = name.toCharArray();
|
||||
if (threadStatus != 0) {
|
||||
@ -1150,7 +1150,7 @@ class Thread implements Runnable {
|
||||
* @see #setName(String)
|
||||
*/
|
||||
public final String getName() {
|
||||
return String.valueOf(name);
|
||||
return new String(name, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user