JVM Learning (1)--Program Counter

Function: Remember the execution address of the next jvm instruction

Each line of java source code will be compiled into multiple lines of jvm instructions. The execution addresses mentioned above are 0, 3, 4, etc. Because execution access is particularly frequent, the bottom layer of the program counter is implemented by registers.

Features:

  • Thread private, as we all know, Java supports multi-threading. When each thread is executed, there will be a program counter. The program counter of each thread here is independent and thread-safe; if it is a single-core CPU, single-threaded , then similarly, when using multi-threading, the multi-threading effect is achieved by allocating time slices by the scheduler. If the first execution is not completed, the currently executed program counter will be stored and the next execution will obtain the time. program, the program counters executed twice will not affect each other.
  • There will never be a memory overflow. This is different from the stack, heap, method area and other program addresses. If they are used improperly, they will cause memory overflow.

おすすめ

転載: blog.csdn.net/weixin_59244784/article/details/132640132