hotspot/src/share/vm/runtime/thread.cpp
void Threads::add(JavaThread* p, bool force_daemon) {
{- -------------------------------------------
(1) (assert)
---------------------------------------- -}
// The threads lock must be owned at this point
assert_locked_or_safepoint(Threads_lock);
{- -------------------------------------------
(1) JavaThread::initialize_queues() を呼んで,
G1GC 用のキュー(SATB and dirty card queues)の初期化を行っておく.
---------------------------------------- -}
// See the comment for this method in thread.hpp for its purpose and
// why it is called here.
p->initialize_queues();
{- -------------------------------------------
(1) Threads::_thread_list にこのスレッドを追加する.
---------------------------------------- -}
p->set_next(_thread_list);
_thread_list = p;
{- -------------------------------------------
(1) _number_of_threads フィールドの値を増やしておく.
---------------------------------------- -}
_number_of_threads++;
{- -------------------------------------------
(1) (変数宣言など)
---------------------------------------- -}
oop threadObj = p->threadObj();
bool daemon = true;
{- -------------------------------------------
(1) daemon スレッドでない場合は, _number_of_non_daemon_threads フィールドの値を増やしておく.
---------------------------------------- -}
// Bootstrapping problem: threadObj can be null for initial
// JavaThread (or for threads attached via JNI)
if ((!force_daemon) && (threadObj == NULL || !java_lang_Thread::is_daemon(threadObj))) {
_number_of_non_daemon_threads++;
daemon = false;
}
{- -------------------------------------------
(1) (プロファイル情報の記録) (See: UsePerfData, ThreadService)
("java.threads.daemon", "java.threads.live", "java.threads.livePeak", "java.threads.started")
---------------------------------------- -}
ThreadService::add_thread(p, daemon);
{- -------------------------------------------
(1) (トレース出力)
---------------------------------------- -}
// Possible GC point.
Events::log("Thread added: " INTPTR_FORMAT, p);
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.