Java VM可以支持多少个线程? [英] How many threads can a Java VM support?

查看:125
本文介绍了Java VM可以支持多少个线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java VM支持多少个线程?这是否因供应商而异?通过操作系统?其他因素?

How many threads can a Java VM support? Does this vary by vendor? by operating system? other factors?

推荐答案

这取决于您在操作系统上使用的CPU,以及其他进程正在执行的CPU,您正在使用的Java版本以及其他因素。我看到Windows服务器在降低机器之前有> 6500个线程。当然,大多数线程都没有做任何事情。一旦机器遇到大约6500个线程(在Java中),整个机器开始出现问题并变得不稳定。

This depends on the CPU you're using, on the OS, on what other processes are doing, on what Java release you're using, and other factors. I've seen a Windows server have > 6500 Threads before bringing the machine down. Most of the threads were not doing anything, of course. Once the machine hit around 6500 Threads (in Java), the whole machine started to have problems and become unstable.

我的经验表明Java(最新版本)可以愉快地消耗尽可能多的线程与计算机本身可以托管没有问题。

My experience shows that Java (recent versions) can happily consume as many Threads as the computer itself can host without problems.

当然,你必须有足够的内存,你必须启动Java足够的内存来做所有的事情线程正在进行并为每个线程创建一个堆栈。任何拥有现代CPU(最新几代AMD或Intel)并具有1-2G内存(取决于操作系统)的机器都可以轻松支持具有数千个线程的JVM。

Of course, you have to have enough RAM and you have to have started Java with enough memory to do everything that the Threads are doing and to have a stack for each Thread. Any machine with a modern CPU (most recent couple generations of AMD or Intel) and with 1 - 2 Gig of memory (depending on OS) can easily support a JVM with thousands of Threads.

如果您需要比这更具体的答案,最好的办法是分析。

If you need a more specific answer than this, your best bet is to profile.

这篇关于Java VM可以支持多少个线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆