java坑之无法创建线程

环境:linux

错误:java.lang.OutOfMemoryError: unable to create new native thread

原因:OS对线程是有限制

解决办法:

在Linux操作系统设定nofile和nproc,具体编辑/etc/security/limits.conf添加如下:

* soft nofile 10240
* hard nofile 10240
* soft nproc 10240
* hard nproc 10240

/etc/security/limits.d/90-nproc.conf添加如下:

* soft nofile 10240
* hard nofile 10240
* soft nproc 10240
* hard nproc 10240

重新登录,通过

 ulimit -a 查看是否生效即可
posted @ 2016-11-23 17:30  wujf  阅读(419)  评论(0编辑  收藏  举报