编译并运行下面的测试类,在运行时可添加JVM参数,比如“java -Xms1024m -Xmx1024m -Xss256k -cp . ThreadCountTest”。
import java.util.concurrent.CountDownLatch;
public class ThreadCountTest {
public static void main(String[] args) {
for (int i = 0;; i++) {
System.out.println(\"i = \" + i);
new Thread(new HoldThread()).start(); }
} }
class HoldThread extends Thread {
CountDownLatch cdl = new CountDownLatch(1);
public HoldThread() {
this.setDaemon(true); } public void run() { try { cdl.await(); } catch (InterruptedException e) { } } }
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- xiaozhentang.com 版权所有 湘ICP备2023022495号-4
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务