生成処理の流れは以下のようになる.
スレッドは Thread クラスのサブクラスとして表現されている.
まず適切な Thread サブクラスのオブジェクトが生成される.
os::create_thread() を呼び出すと, 実際にスレッドの生成が行われる.
生成直後のスレッドは実行が停止されている.
os::start_thread() を呼ぶことで, 実際に実行が開始される.
-> (Thread クラスの種々のサブクラスのコンストラクタ)
-> Thread::Thread()
-> os::create_thread()
-> OS によって処理が異なる.
* Linux の場合
-> OSThread::OSThread()
-> OSThread::pd_initialize()
-> pthread_attr_setdetachstate()
-> pthread_attr_setstacksize() (<= 必要があれば呼び出す)
-> pthread_attr_setguardsize()
-> pthread_create() (<= なお, エントリポイントとしては java_start() 関数が指定されている)
-> Monitor::wait()
(生成したスレッドと同期を取る処理. java_start() 内から Monitor::notify_all() されるまで待機)
* Solaris の場合
-> OSThread::OSThread()
-> OSThread::pd_initialize()
-> thr_setconcurrency() (<= 必要があれば呼び出す)
-> thr_create() (<= なお, エントリポイントとしては java_start() 関数が指定されている)
-> thr_setprio() (<= 必要があれば呼び出す)
* Windows の場合
-> OSThread::OSThread()
-> OSThread::pd_initialize()
-> CreateEvent()
-> _beginthredex() (<= なお, エントリポイントとしては java_start() 関数が指定されている)
-> os::start_thread()
-> OSThread::set_state()
-> os::pd_start_thread()
-> OS によって処理が異なる.
* Linux の場合
-> Monitor::notify()
(生成したスレッドと同期を取る処理. java_start() 内で Monitor::wait() しているスレッドを起床させる)
* Solaris の場合
-> thr_continue()
* Windows の場合
-> ResumeThread()
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.