Mercurial > hg > graal-jvmci-8
diff src/share/vm/runtime/thread.cpp @ 20393:966601b12d4f
8057535: add a thread extension class
Reviewed-by: mgerdin, bdelsart, jcoomes
author | sla |
---|---|
date | Thu, 04 Sep 2014 11:21:08 +0200 |
parents | 833b0f92429a |
children | 46f9331baed5 |
line wrap: on
line diff
--- a/src/share/vm/runtime/thread.cpp Wed Sep 03 17:01:57 2014 +0200 +++ b/src/share/vm/runtime/thread.cpp Thu Sep 04 11:21:08 2014 +0200 @@ -860,6 +860,7 @@ st->print("os_prio=%d ", os_prio); } st->print("tid=" INTPTR_FORMAT " ", this); + ext().print_on(st); osthread()->print_on(st); } debug_only(if (WizardMode) print_owned_locks_on(st);) @@ -3021,6 +3022,8 @@ // Push the Java priority down to the native thread; needs Threads_lock Thread::set_priority(this, prio); + prepare_ext(); + // Add the new thread to the Threads list and set it in motion. // We must have threads lock in order to call Threads::add. // It is crucial that we do not block before the thread is @@ -3875,6 +3878,24 @@ } } +JavaThread* Threads::find_java_thread_from_java_tid(jlong java_tid) { + assert(Threads_lock->owned_by_self(), "Must hold Threads_lock"); + + JavaThread* java_thread = NULL; + // Sequential search for now. Need to do better optimization later. + for (JavaThread* thread = Threads::first(); thread != NULL; thread = thread->next()) { + oop tobj = thread->threadObj(); + if (!thread->is_exiting() && + tobj != NULL && + java_tid == java_lang_Thread::thread_id(tobj)) { + java_thread = thread; + break; + } + } + return java_thread; +} + + // Last thread running calls java.lang.Shutdown.shutdown() void JavaThread::invoke_shutdown_hooks() { HandleMark hm(this);