线程内存溢出!!!!
程序员文章站
2022-07-12 20:38:25
...
引用
创建线程,内存溢出异常
import com.google.common.collect.Lists; import java.util.List; /** * @Author admin Date: 2017/6/19 10:40 * @description: 创建线程导致内存溢出异常 */ public class JavaVMStackOOM { private void dontStop(){ while(true){ } } public void stackLeakByThread(){ while (true){ Thread thread = new Thread(new Runnable() { public void run() { dontStop(); } }); thread.start(); } } public static void main(String[] args){ JavaVMStackOOM javaVMStackOOM = new JavaVMStackOOM(); javaVMStackOOM.stackLeakByThread(); } } //自行扩展!!
注意!运行前要保存好东西,因为会死机