Executors enhancement
Bernd Eckenfels
ecki at zusammenkunft.net
Sun Aug 14 02:21:17 UTC 2016
Hello,
yes, an ExecutorService or Executor or ForkJoinPool depending on the
minimum requirements you have.
As a default you can eithter use
ForJoinPool.commonPool() or Executors.newSingleThreadExecutor() or a
DirectExecutor() if you dont want to handle the null case special.
BTW: little nit, I would add the long explanation what the ES is used
for tho the setter not the getter.
Gruss
Bernd
Am Sun, 14 Aug 2016 03:49:30 +0200
schrieb Christian Schulte <cs at schulte.it>:
> Am 08/09/16 um 19:04 schrieb ecki at zusammenkunft.net:
> > So it is a good idea to find a good shared default, but an API quite
> > seldomly can isolate itself and the users about those aspects. So
> > always allow to provide an alternate Executor. This also helps with
> > thread naming, thread context, interceptors and error handlers.
>
> That way?
>
>
> /**
> * Gets the {@code ExecutorService} used to run tasks in parallel.
> * <p>
> * The {@code ExecutorService} used to run tasks in parallel is an
> optional entity. If no such service is
> * provided by an application, no parallelization is performed.
> Configuration or lifecycle management of that
> * {@code ExecutorService} is the responsibility of the
> application.
> * </p>
> *
> * @return The {@code ExecutorService} used to run tasks in
> parallel, or {@code null}.
> *
> * @since 1.10
> */
> public final ExecutorService getExecutorService()
> {
> return this.executorService;
> }
>
> /**
> * Sets the {@code ExecutorService} to be used to run tasks in
> parallel. *
> * @param value The {@code ExecutorService} to be used to run
> tasks in parallel, or {@code null}, to not make use
> * of any parallelization.
> *
> * @since 1.10
> */
> public final void setExecutorService( final ExecutorService value
> ) {
> this.executorService = value;
> }
>
> Regards,
More information about the core-libs-dev
mailing list