< prev index next >
src/java.base/share/classes/java/lang/Thread.java
Print this page
@@ -1224,11 +1224,12 @@
throw new NullPointerException("name cannot be null");
}
this.name = name;
if (threadStatus != 0) {
- setNativeName(name);
+ // Don't modify JNI-attached threads
+ setNativeName(name, false);
}
}
/**
* Returns this thread's name.
@@ -2140,7 +2141,10 @@
private native void setPriority0(int newPriority);
private native void stop0(Object o);
private native void suspend0();
private native void resume0();
private native void interrupt0();
- private native void setNativeName(String name);
+
+ // May be called directly via JNI or reflection (when permitted) to
+ // allow JNI-attached threads to set their native name
+ private native void setNativeName(String name, boolean allowAttachedThread);
}
< prev index next >