4149 thread_name = args->name; // may be NULL
4150 }
4151 if (group == NULL) group = Universe::main_thread_group();
4152
4153 // Create Java level thread object and attach it to this thread
4154 bool attach_failed = false;
4155 {
4156 EXCEPTION_MARK;
4157 HandleMark hm(THREAD);
4158 Handle thread_group(THREAD, group);
4159 thread->allocate_threadObj(thread_group, thread_name, daemon, THREAD);
4160 if (HAS_PENDING_EXCEPTION) {
4161 CLEAR_PENDING_EXCEPTION;
4162 // cleanup outside the handle mark.
4163 attach_failed = true;
4164 }
4165 }
4166
4167 if (attach_failed) {
4168 // Added missing cleanup
4169 thread->cleanup_failed_attach_current_thread();
4170 return JNI_ERR;
4171 }
4172
4173 // mark the thread as no longer attaching
4174 // this uses a fence to push the change through so we don't have
4175 // to regrab the threads_lock
4176 thread->set_done_attaching_via_jni();
4177
4178 // Set java thread status.
4179 java_lang_Thread::set_thread_status(thread->threadObj(),
4180 java_lang_Thread::RUNNABLE);
4181
4182 // Notify the debugger
4183 if (JvmtiExport::should_post_thread_life()) {
4184 JvmtiExport::post_thread_start(thread);
4185 }
4186
4187 post_thread_start_event(thread);
4188
4189 *(JNIEnv**)penv = thread->jni_environment();
|
4149 thread_name = args->name; // may be NULL
4150 }
4151 if (group == NULL) group = Universe::main_thread_group();
4152
4153 // Create Java level thread object and attach it to this thread
4154 bool attach_failed = false;
4155 {
4156 EXCEPTION_MARK;
4157 HandleMark hm(THREAD);
4158 Handle thread_group(THREAD, group);
4159 thread->allocate_threadObj(thread_group, thread_name, daemon, THREAD);
4160 if (HAS_PENDING_EXCEPTION) {
4161 CLEAR_PENDING_EXCEPTION;
4162 // cleanup outside the handle mark.
4163 attach_failed = true;
4164 }
4165 }
4166
4167 if (attach_failed) {
4168 // Added missing cleanup
4169 thread->cleanup_failed_attach_current_thread(daemon);
4170 return JNI_ERR;
4171 }
4172
4173 // mark the thread as no longer attaching
4174 // this uses a fence to push the change through so we don't have
4175 // to regrab the threads_lock
4176 thread->set_done_attaching_via_jni();
4177
4178 // Set java thread status.
4179 java_lang_Thread::set_thread_status(thread->threadObj(),
4180 java_lang_Thread::RUNNABLE);
4181
4182 // Notify the debugger
4183 if (JvmtiExport::should_post_thread_life()) {
4184 JvmtiExport::post_thread_start(thread);
4185 }
4186
4187 post_thread_start_event(thread);
4188
4189 *(JNIEnv**)penv = thread->jni_environment();
|