Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #31685
| From | Marcel Mueller <news.5.maazl@spamgourmet.org> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: How to programatically limit the number of threads in a java |
| Date | 2015-05-12 21:19 +0200 |
| Organization | MB-NET.NET for Open-News-Network e.V. |
| Message-ID | <mitjo5$dn$1@gwaiyur.mb-net.net> (permalink) |
| References | <d2e186ee-1bab-4737-9462-9031b6e2839e@googlegroups.com> |
On 12.05.15 17.49, Ajay Paul wrote: > How to programatically limit the number of threads in a java. Simply do not start more threads than wanted. :-) Java will not start more than one thread automatically. > I know the settings in different application servers such as websphere to do that, Exactly. The number of threads need to be controlled by the application that starts them. Web application servers are this kind of application. > but how do we do it programatically. Not at all. Even if the JVM could control that what should be the action when the application requests another thread? Throw a NoMoreThreadsException? This exception could not be reasonably handled by the application. I.e. it will cause unexpected aborts or other malfunction. The effect is comparable to out of memory exceptions, since some libraries rely on the availability of (a limited number of) threads, e.g. JMS or DBMS drivers. So basically you will need to restart the application server after that exception. Wait until another thread terminates? This is called a thread pool. However, the application could deadlock, because the expected task may not complete in a reasonable time, e.g. especially when other threads wait for this one. Thread pools are commonly used by applications servers but they must handle only independent requests. Marcel
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to programatically limit the number of threads in a java Ajay Paul <ajaykpaul@gmail.com> - 2015-05-12 08:49 -0700
Re: How to programatically limit the number of threads in a java Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-05-12 12:01 -0400
Re: How to programatically limit the number of threads in a java Marcel Mueller <news.5.maazl@spamgourmet.org> - 2015-05-12 21:19 +0200
Re: How to programatically limit the number of threads in a java Joerg Meier <joergmmeier@arcor.de> - 2015-05-13 09:48 +0200
Re: How to programatically limit the number of threads in a java Arne Vajhøj <arne@vajhoej.dk> - 2015-06-03 21:51 -0400
Re: How to programatically limit the number of threads in a java dolnotmail@nomail.com (e) - 2015-06-15 03:33 +0000
Re: How to programatically limit the number of threads in a java Robert Klemme <shortcutter@googlemail.com> - 2015-06-15 08:23 +0200
Re: How to programatically limit the number of threads in a java Arne Vajhøj <arne@vajhoej.dk> - 2015-06-03 21:50 -0400
csiph-web