Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #10360

Re: Thread question

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From markspace <-@.>
Newsgroups comp.lang.java.programmer
Subject Re: Thread question
Date Wed, 30 Nov 2011 06:04:14 -0800
Organization A noiseless patient Spider
Lines 29
Message-ID <jb5d4v$2k4$1@dont-email.me> (permalink)
References <i9tbd7ppgalucct4i2t2agj9hldjumnmk4@4ax.com> <jb5cbf$t1t$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Wed, 30 Nov 2011 14:04:15 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="2692"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ZjvwNfQgjOAOqjtQ0I1Cx7ugkUN7+4vk="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0
In-Reply-To <jb5cbf$t1t$1@dont-email.me>
Cancel-Lock sha1:iodcQ8wjWMIc/DUtf8QBzqVtwJU=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10360

Show key headers only | View raw


On 11/30/2011 5:50 AM, markspace wrote:
> On 11/30/2011 1:31 AM, Roedy Green wrote:
>
>> 1. some sort of throttle on releasing them that I don't swamp the JVM.
>
> I wouldn't bother. It's actually well known that for fast efficient IO
> you should start as many threads as possible. 21 threads aren't going to
> swamp anything.
>
> If you start to have in excess of say 100 to 1000 threads, then maybe
> you can think about a throttle. Until there's a chance of that many
> threads, you're just gold-plating your software.
>
> <http://en.wikipedia.org/wiki/Gold_plating_%28software_engineering%29>
>


Reading the docs carefully, it looks like Executors::newFixedThreadPool 
might only allocate new threads as it needs them, up to a maximum. 
Rather than say allocate the maximum number of specified threads 
immediately.  If it does, this would be ideal for throttling your tasks.

Even if it doesn't, a relatively small number of threads, say 
"newFixedThreadPool(50)" is probably much much easier than trying to 
invent some throttling mechanism yourself.


<http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html#newFixedThreadPool%28int%29>

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Thread question Roedy Green <see_website@mindprod.com.invalid> - 2011-11-30 01:31 -0800
  Re: Thread question Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-11-30 01:48 -0800
  Re: Thread question Roedy Green <see_website@mindprod.com.invalid> - 2011-11-30 02:32 -0800
    Re: Thread question Roedy Green <see_website@mindprod.com.invalid> - 2011-11-30 02:48 -0800
    Re: Thread question Patricia Shanahan <pats@acm.org> - 2011-11-30 03:11 -0800
      Re: Thread question Paul Cager <paul.cager@googlemail.com> - 2011-11-30 07:10 -0800
        Re: Thread question Patricia Shanahan <pats@acm.org> - 2011-11-30 09:34 -0800
    Re: Thread question Roedy Green <see_website@mindprod.com.invalid> - 2011-11-30 06:10 -0800
      Re: Thread question markspace <-@.> - 2011-11-30 06:13 -0800
      Re: Thread question Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-11-30 11:53 -0800
  Re: Thread question Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-30 07:28 -0500
    Re: Thread question markspace <-@.> - 2011-11-30 05:30 -0800
      Re: Thread question Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-30 21:04 -0500
        Re: Thread question markspace <-@.> - 2011-11-30 18:28 -0800
  Re: Thread question markspace <-@.> - 2011-11-30 05:50 -0800
    Re: Thread question markspace <-@.> - 2011-11-30 06:04 -0800
  Re: Thread question Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-11-30 11:48 -0800
  Re: Thread question Roedy Green <see_website@mindprod.com.invalid> - 2011-11-30 13:23 -0800

csiph-web