jvm线程分类
代码如下:
enum ThreadType {
vm_thread,
cgc_thread, // Concurrent GC thread
pgc_thread, // Parallel GC thread
java_thread,
compiler_thread,
watcher_thread
};
enum ThreadPriority { // JLS 20.20.1-3
NoPriority = -1, // Initial non-priority value
MinPriority = 1, // Minimum priority
NormPriority = 5, // Normal (non-daemon) priority
NearMaxPriority = 9, // High priority, used for VMThread
MaxPriority = 10 // Highest priority, used for WatcherThread
// ensures that VMThread doesn't starve profiler
};
enum ThreadState {
ALLOCATED, // Memory has been allocated but not initialized
INITIALIZED, // The thread has been initialized but yet started
RUNNABLE, // Has been started and is runnable, but not necessarily running
MONITOR_WAIT, // Waiting on a contended monitor lock
CONDVAR_WAIT, // Waiting on a condition variable
OBJECT_WAIT, // Waiting on an Object.wait() call
BREAKPOINTED, // Suspended at breakpoint
SLEEPING, // Thread.sleep()
ZOMBIE // All done, but not reclaimed yet
};
JavaThread Threads Thread VmThread
JNI_CreateJavaVM
Threads::create_vm
|--> Thread::set_as_starting_thread
|
|--> os::create_main_thread
|
|-->create_os_thread
代码如下:
enum ThreadType {
vm_thread,
cgc_thread, // Concurrent GC thread
pgc_thread, // Parallel GC thread
java_thread,
compiler_thread,
watcher_thread
};
enum ThreadPriority { // JLS 20.20.1-3
NoPriority = -1, // Initial non-priority value
MinPriority = 1, // Minimum priority
NormPriority = 5, // Normal (non-daemon) priority
NearMaxPriority = 9, // High priority, used for VMThread
MaxPriority = 10 // Highest priority, used for WatcherThread
// ensures that VMThread doesn't starve profiler
};
enum ThreadState {
ALLOCATED, // Memory has been allocated but not initialized
INITIALIZED, // The thread has been initialized but yet started
RUNNABLE, // Has been started and is runnable, but not necessarily running
MONITOR_WAIT, // Waiting on a contended monitor lock
CONDVAR_WAIT, // Waiting on a condition variable
OBJECT_WAIT, // Waiting on an Object.wait() call
BREAKPOINTED, // Suspended at breakpoint
SLEEPING, // Thread.sleep()
ZOMBIE // All done, but not reclaimed yet
};
JavaThread Threads Thread VmThread
JNI_CreateJavaVM
Threads::create_vm
|--> Thread::set_as_starting_thread
|
|--> os::create_main_thread
|
|-->create_os_thread