Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: How to programatically limit the number of threads in a java Date: Tue, 12 May 2015 12:01:16 -0400 Organization: A noiseless patient Spider Lines: 18 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 12 May 2015 16:00:17 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="858a9d65d95f4ea4d355bd116aa2cdbf"; logging-data="8710"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+rCSXUyByM5vuK1Vr1AStQ" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: Cancel-Lock: sha1:dKiZdLTAAimPMHBaI1xQ4nQzsuw= Xref: csiph.com comp.lang.java.programmer:31681 On 5/12/2015 11:49 AM, Ajay Paul wrote: > How to programatically limit the number of threads in a java. I know the settings in different application servers such as websphere to do that, but how do we do it programatically. By starting the number of threads you want, no more and no less. That's not a perfect answer, because it controls only the number of threads *you* start (or allow to finish, or don't start at all). If classes not under your direct control start their own threads, or if the JVM itself starts threads for its own purposes, they are pretty much immune to your influence except insofar as they offer a means to provide hints and limits. Do you want to limit the total number of threads running in the JVM? Why? What are you trying to accomplish? -- esosman@comcast-dot-net.invalid "Don't be afraid of work. Make work afraid of you." -- TLM