< prev index next >

src/share/vm/prims/jvm.cpp

Print this page

        

@@ -3178,20 +3178,18 @@
   if (JvmtiExport::should_post_data_dump()) {
     JvmtiExport::post_data_dump();
   }
 JVM_END
 
-JVM_ENTRY(void, JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring name))
+JVM_ENTRY(void, JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring name, jboolean allowAttachedThread))
   JVMWrapper("JVM_SetNativeThreadName");
   ResourceMark rm(THREAD);
   oop java_thread = JNIHandles::resolve_non_null(jthread);
   JavaThread* thr = java_lang_Thread::thread(java_thread);
   // Thread naming only supported for the current thread, doesn't work for
   // target threads.
-  if (Thread::current() == thr && !thr->has_attached_via_jni()) {
-    // we don't set the name of an attached thread to avoid stepping
-    // on other programs
+  if (Thread::current() == thr && (allowAttachedThread || !thr->has_attached_via_jni())) {
     const char *thread_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name));
     os::set_native_thread_name(thread_name);
   }
 JVM_END
 
< prev index next >