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