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

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

问题描述

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

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

推荐答案

这取决于您使用的 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.

当然,您必须有足够的 RAM,并且您必须以足够的内存启动 Java 来执行线程正在执行的所有操作,并为每个线程拥有一个堆栈.任何配备现代 CPU(最近几代 AMD 或 Intel)和 1 - 2 Gig 内存(取决于操作系统)的机器都可以轻松支持具有 数千 个线程的 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天全站免登陆