含义的解释如下
Constant | Description |
---|---|
JVMTI_THREAD_STATE_ALIVE | Thread is alive. Zero if thread is new (not started) or terminated. |
JVMTI_THREAD_STATE_TERMINATED | Thread has completed execution. |
JVMTI_THREAD_STATE_RUNNABLE | Thread is runnable. |
JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER | Thread is waiting to enter a synchronization block/method or, after an Object.wait(), waiting to re-enter a synchronization block/method. |
JVMTI_THREAD_STATE_WAITING | Thread is waiting. |
JVMTI_THREAD_STATE_WAITING_INDEFINITELY | Thread is waiting without a timeout. For example, Object.wait(). |
JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT | Thread is waiting with a maximum time to wait specified. For example, Object.wait(long). |
JVMTI_THREAD_STATE_SLEEPING | Thread is sleeping -- Thread.sleep(long). |
JVMTI_THREAD_STATE_IN_OBJECT_WAIT | Thread is waiting on an object monitor -- Object.wait. |
JVMTI_THREAD_STATE_PARKED | Thread is parked, for example: LockSupport.park, LockSupport.parkUtil and LockSupport.parkNanos. |
JVMTI_THREAD_STATE_SUSPENDED | Thread suspended. java.lang.Thread.suspend() or a JVM TI suspend function (such as SuspendThread) has been called on the thread. If this bit is set, the other bits refer to the thread state before suspension. |
JVMTI_THREAD_STATE_INTERRUPTED | Thread has been interrupted. |
JVMTI_THREAD_STATE_IN_NATIVE | Thread is in native code--that is, a native method is running which has not called back into the VM or Java programming language code.This flag is not set when running VM compiled Java programming language code nor is it set when running VM code or VM support code. Native VM interface functions, such as JNI and JVM TI functions, may be implemented as VM code. |
BLOCKED与WAITING有什么区别
volatile
关键字的用意是将被该关键字修饰的成员变量及时被刷新到主内存里面。
但是volatile
并不能保证线程安全性。它除了可见性之外还有防止指令重排优化的功能。
public class Singleton {
private static volatile Singleton singleton;
private Singleton() {
}
public static Singleton getInstance() {
if (singleton == null) {
synchronized (Singleton.class) {
if (singleton == null) {
//防止指令重排
singleton = new Singleton();
}
}
}
return singleton;
}
}
什么情况下会出现full gc,什么情况出现young gc
JVM如何加载字节码文件
通常由两种方式
- 指针碰撞
- 空闲列表
可以将内存分配安排在每个线程独有的空间进行,每个线程首先在堆内存中分配一小块内存,称为本地分配缓存(TLAB : Thread Local Allocation Buffer)。
分配内存时,只需要在自己的分配缓存中分配即可,由于这个内存区域是线程私有的,所以不会出现并发问题。
可以使用 -XX:+/-UseTLAB 参数来设定 JVM 是否开启 TLAB
内存分配之后需要对该对象进行设置,如对象头
多个线程同时请求内存,如何分配