当前位置:网站首页>JVM | runtime data area; Program counter (PC register);
JVM | runtime data area; Program counter (PC register);
2022-06-11 21:28:00 【z754916067】
Catalog
Run time data area
- Method area : After the class is loaded, it is placed in the method area
- Program counter
- Native Method Stack
- Pile up
- Virtual machine stack
The relationship between data area and thread
Private to each individual thread : Program counter , Stack , Local stack
Sharing between threads : Pile up , Out of heap memory ( Method area ( Permanent generation or meta space ) Code cache )
Threads
A thread is a running unit in a program ,JVM Allows an application to have multiple threads executing in parallel .
Once the local thread is initialized successfully , It's going to call Java In thread run() Method .
Program counter (PC register )
- It's a small memory space , It's also the fastest running storage area .
- A thread has only one method executing at any one time , It's called “ The current method ”.
- The program counter stores what the current thread is executing Java Methodical JVM Instruction address .
effect
PC Registers are used to store the address to the next instruction , Also about to execute the instruction code . The execution engine reads the next instruction .
Use examples
The program counter stores the address of the next instruction , The execution engine looks for the corresponding statement according to this address , To operate .
common problem
1. Use PC What's the use of registers storing bytecode instruction addresses ?
answer :CPU You need to constantly switch threads , After switching back, you have to know where to start .
2. Why use PC Register records the execution address of the current thread ?
answer :JVM The bytecode interpreter needs to be changed PC Register to determine what kind of bytecode instruction should be executed next .
The reason why threads are private
So called multithreading , The method of only one thread will be executed in a specific time period ,CPU I'll keep switching tasks , This inevitably leads to frequent interruptions or recoveries .
In order to accurately record the current bytecode instruction address that each thread is executing , The best way is to assign one to each thread PC register .
In this way, each thread can perform independent calculation .
边栏推荐
- LeetCode-98-验证二叉搜索树
- JVM runtime constant pool and direct memory
- 作为一名 ABAP 资深顾问,下一步可以选择哪一门 SAP 技术作为主攻方向?
- Redis basic data type (set)
- Expérience 10 génération de courbes bezier - amélioration expérimentale - génération de courbes B - spline par point de contrôle
- Redis basic data type (hash)
- JUnit tests multithreaded code, and the sub thread does not run
- 实验10 Bezier曲线生成-实验提高-交互式生成B样条曲线
- Comprehensive RTL code design method and precautions
- Codeworks round 744 (Div. 3) problem solving Report
猜你喜欢

Part I physical layer

Solve the problem of img 5px spacing

LeetCode-110-平衡二叉树

SQL的语法

LeetCode-129-求根节点到叶节点数字之和
![[Part 14] source code analysis and application details of completionservice class [key]](/img/41/9f5383d6eafb32723e29c15da3a1af.jpg)
[Part 14] source code analysis and application details of completionservice class [key]
![[Part 13] source code analysis and application details of completabilefuture class [key]](/img/cf/87c60a1d46835f3f0dae9f44970de4.jpg)
[Part 13] source code analysis and application details of completabilefuture class [key]

One article to show you how to understand the harmonyos application on the shelves

Tensorflow 2. X Getting Started tutorial

关于斜率优化
随机推荐
线性表的链式存储结构
JVM method area
Refresh and upgrade | innovation, starting from cloud store
Analysis on the development history and market development status of China's system integration industry in 2020 [figure]
Educational Codeforces Round 114 (Rated for Div. 2) D
Redis transaction
Database daily question --- day 9: salesperson
JVM heap
Apache local multi port configuration
JVM之堆区
Regular check matches positive integer or decimal limit between [0-100] and [0-1000]
Educational Codeforces Round 114 (Rated for Div. 2) D
How to manually drag nodes in the Obsidian relationship graph
[Part 16] copyonwritearraylist source code analysis and application details [key]
Supplementary questions for the training ground on September 11, 2021
Educational codeforces round 111 (rated for Div. 2) C Supplement
杭电中超9 1006 Guess the Weight
Using the sap ui5 cli command line tool to build and run SAP ui5 applications
Cs144 lab0 lab1 record
table_ Display status