编写高性能的Java代码需要注意的4个问题
一、并发
Unable to create new native thread ……
问题1:Java中创建一个线程消耗多少内存?
每个线程有独自的栈内存,共享堆内存
问题2:一台机器可以创建多少线程?
CPU,内存,操作系统,JVM,应用服务器
我们编写一段示例代码,来验证下线程池与非线程池的区别:
//线程池和非线程池的区别
public class ThreadPool {
public static int times = 100;//100,1000,10000
public static ArrayBlockingQueue arrayWorkQueue = new ArrayBlockingQueue(1000);
public static ExecutorService threadP