@Override
public void run() {
//ThreadLocalRandom random = ThreadLocalRandom.current();
while(true)
{
try {
String str = new String("123");
Thread.sleep(100);
System.out.println("....." + Thread.currentThread().getName()+" is live");
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static void main(String[] args)
{
for(int i=0;i<4000;i++){
EmptyTask task = new EmptyTask();
task.start();
}
}
运行起来以后,会短时间内占用差不多1G内存
@Override
public void run() {
ThreadLocalRandom random = ThreadLocalRandom.current();
while(true)
{
try {
String str = new String("123");
Thread.sleep(100);
System.out.println("....." + Thread.currentThread().getName()+" is live");
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static void main(String[] args)
{
for(int i=0;i<4000;i++){
EmptyTask task = new EmptyTask();
task.start();
}
}
内存占用的峰值就只有400M左右,不明白是什么原因引起的