码迷,mamicode.com
首页 > 其他好文 > 详细

Stop The World

时间:2017-04-08 00:14:12      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:mil   shm   try   hash   com   extend   time   gcd   exce   

import java.util.HashMap;

/**
* Created by wb-xxd249566 on 2017/4/5.
* -Xmx1g -Xms1g -Xmn512k -XX:+UseSerialGC -Xloggc:gc.log -XX:+PrintGCDetails
*/
public class StopWorldTest {
public static class MyThread extends Thread{
HashMap map = new HashMap();

@Override
public void run() {
try {
while (true){
if (map.size()*512/1024/1024>=550){
map.clear();
System.out.println("clean map");
}
byte[] b1;
for (int i=0;i<100;i++){
b1 = new byte[512];
map.put(System.nanoTime(),b1);
}
Thread.sleep(1);
}
}catch (Exception e){

}
}
}

public static class PrintThread extends Thread{
public static final long startTime = System.currentTimeMillis();

@Override
public void run() {
try {
while (true){
long t = System.currentTimeMillis()-startTime;
System.out.println(t/1000+"."+t%1000);
Thread.sleep(100);
}
}catch (Exception e){

}
}
}

public static void main(String[] args){
MyThread t = new MyThread();
PrintThread p = new PrintThread();
t.start();
p.start();
}
}
技术分享

Stop The World

标签:mil   shm   try   hash   com   extend   time   gcd   exce   

原文地址:http://www.cnblogs.com/xxdfly/p/6680601.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!