The program counter is a small memory space that can be seen as the line number indicator that is executed by the current thread. In the concept model of virtual machines (only the conceptual model, a variety of virtual machines may be implemented in some more efficient way), the bytecode interpreter studio is to select the next byte code instruction to execute, branch, loop, jump, exception handling by changing the value of this counter, Basic functions such as thread recovery need to rely on this counter to complete.
Because the multithreading of a Java Virtual machine is implemented in a way that threads take turns switching and allocating processor execution time, at any given moment, a processor (a kernel for a multicore processor) simply executes the instructions in one thread. Therefore, in order for the thread to switch back to the correct execution location, each thread needs a separate program counter, the counters between the threads do not affect each other, isolated storage, we call this kind of memory area "thread-private memory."
If the thread is executing a Java method, this counter records the address of the executing virtual machine bytecode instruction, and if the native method is being executed, the counter value is empty. The secondary memory area is the only area in the Java Virtual Machine specification that does not stipulate outofmemoryerror conditions!
Java Virtual Machine--->> program counters