1.代码

package com.study.threadpool;

import java.util.concurrent.CountDownLatch;

public class ThreadDemo {
	public static void main(String[] args) {
		CountDownLatch cdl = new CountDownLatch(1);
		try {
			Thread.sleep(2000L);
		}catch(InterruptedException e)
		{
			e.printStackTrace();
		}
		for(int i=0;i<5000;i++)
		{
			new Thread(new Runnable() {
				public void run() {
					try {
						cdl.await();
					}catch(InterruptedException e) {
						e.printStackTrace();
					}
				}
			}).start();
			System.out.println("i = " + i);
		}
	}
}

2. java VisualVM工具

    用java VisualVM工具查看堆内存的耗用情况。

Java 线程 - 测试线程耗用堆内存

Java 线程 - 测试线程耗用堆内存

 

相关文章:

  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2021-06-11
  • 2021-04-09
  • 2022-01-16
猜你喜欢
  • 2022-01-15
  • 2021-10-29
  • 2022-12-23
  • 2021-12-08
  • 2021-09-10
相关资源
相似解决方案