Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34591
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: future run unlimited |
| Date | 2016-06-10 10:17 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <njei6e$si6$1@dont-email.me> (permalink) |
| References | <2b896a25-e53e-4398-b423-fca4d040c3f9@googlegroups.com> |
On 6/10/2016 9:30 AM, Philipp Kraus wrote:
> Hello,
>
> I would like to build an unlimited working process with an executor new-work-stealing executor.
> I have a stream of callable objects and I submit them to the executor, and I will get on the submit call a future of my input, but after the object is done, I will run it again within the pool. In some pseudo-code illustrating:
>
> mycallablestream
> .map( i-> pool.submit(i))
> .filter( i -> i is done)
> .foreach( i -> mycallable.put(i) )
If you want to call put() after each Callable completes, this won't
do it. The filter() stage will not wait for completion; it will just
test "Has this Callable already completed?" and reject those that are
still in progress or have not started. Result: The few (probably)
Callables that complete in a very small amount of time will pass to
the forEach() stage, and the stream will finish while the others are
still pending or in progress.
I'm not sure exactly what you want to do, but perhaps you should
take a look at ExecutorCompletionService.
> How can I do this with the execution service and how I can shutdown the pool in a correct way if my user creates an event for closing (from UI)?
What is the "correct way?"
- Wait for all submitted tasks to complete, then shut down?
- Discard the tasks that have not started, wait for those already
in progress, then shut down?
- Discard the un-started tasks, cancel those in progress, then
shut down?
- Something else?
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
future run unlimited Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-06-10 06:30 -0700
Re: future run unlimited Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-06-10 10:17 -0400
Re: future run unlimited Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-06-10 07:34 -0700
Re: future run unlimited Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-06-10 11:48 -0400
Re: future run unlimited Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-06-10 12:49 -0700
Re: future run unlimited Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-06-11 08:22 -0400
csiph-web