JVM Run-Time Data Areas.

Ref:  JVM Run-Time Data Areas

1 class SimpleThread extends Thread {
2     public SimpleThread(String name) {
3         super(name);
4     }
5     public void run() {
6         for(int i = 0; i < 50; i++)    //every 'i' variable corresponds to an individual thread,that is,each thread contains its own 'i' variable.
7             println("thread name = \"" + Thread.currentThread().getName() + "\",id=" + getId() +" run = " + i);
8     }
9 }

 

 

JVM-runtime-data-area

1. Data Areas for Each Individual Thread (not shared)

  Data Areas for each individual thread include program counter register, JVM Stack, and Native Method Stack. They are all created when a new thread is created.

  Program Counter Register: it is used to control each execution of each thread.
 
  JVM Stack: It contains frames which is demonstrated in the diagram below.

  Native Method Stack: it is used to support native methods, i.e., non-Java language methods.  

2. Data Areas Shared by All Threads

  All threads share Heap and Method Area.

 

  Heap: it is the area that we most frequently deal with. It stores arrays and objects, created when JVM starts up. Garbage Collection works in this area.

 

  Method Area: it stores run-time constant pool, field and method data, and methods and constructors code。 

 

  Runtime Constant Pool: It is a per-class or per-interface run-time representation of the constant_pool table in a class file. It contains several kind-s of constants, ranging from numeric literals known at compile-time to method and field references that must be resolved at run-time.

 

  

  Stack contains Frames, and a frame is pushed to the stack when a method is invoked. A frame contains local variable array, Operand Stack, Reference to Constant Pool.

  For more information, please go to the offical JVM specification site.

References:
1. JVM Specification – Run-Time Data Areas 
2. Java Bytecode Fundamentals

  

转载于:https://www.cnblogs.com/listened/p/3608854.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值