Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #10354
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Eric Sosman <esosman@ieee-dot-org.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Thread question |
| Date | Wed, 30 Nov 2011 07:28:26 -0500 |
| Organization | A noiseless patient Spider |
| Lines | 35 |
| Message-ID | <jb57hc$v6g$1@dont-email.me> (permalink) |
| References | <i9tbd7ppgalucct4i2t2agj9hldjumnmk4@4ax.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Wed, 30 Nov 2011 12:28:28 +0000 (UTC) |
| Injection-Info | mx04.eternal-september.org; posting-host="HSlJAUb3pGXi3i7ZL/HoAw"; logging-data="31952"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18TE69kYOCntKttu4FdQzg1" |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20111105 Thunderbird/8.0 |
| In-Reply-To | <i9tbd7ppgalucct4i2t2agj9hldjumnmk4@4ax.com> |
| Cancel-Lock | sha1:nyQHH1ZKGegJDgAzZjRiQhof+4s= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10354 |
Show key headers only | View raw
On 11/30/2011 4:31 AM, Roedy Green wrote:
> The application is I have a list of 1200 books and a list of 21 online
> bookstores. I want to find out which bookstores carry the book. I
> have code now that given a book and bookstore will find out if it
> carries it and records the result. It probes the appropriate page and
> scans for clues, positive and negative.
>
> The process is very slow because it mostly spends its time waiting for
> the bookstore to respond. I figured I could fairly easily make one
> book-x-store probe into a Runnable. Happily there is only very simple
> interactions between Runnables.
>
> You could imagine setting all the Runnables loose at once.
>
> I need two features:
>
> 1. some sort of throttle on releasing them that I don't swamp the JVM.
Use a java.util.concurrent.ExecutorService. There's a large
number of ways to configure them, but I'd suggest starting out
simple, with a fixed-size thread pool plucking tasks from a queue.
> 2. some way of knowing when the last one completed.
A simple counter will do it. Note that you'll likely want to
be able to proceed without waiting for every last probe to complete:
If you've got twenty answers but qcvfl.com[*] appears hung, it may be
best to abandon the lallygagger and proceed with what you've got. So,
consider having a time-out as an alternative "completion" signal.
[*]"Quaint and Curious Volumes of Forgotten Lore."
--
Eric Sosman
esosman@ieee-dot-org.invalid
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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