Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 63afbed

Browse files
committed
updated readme
1 parent 8823822 commit 63afbed

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

README.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,8 @@ new CallExecutor<>(config)
418418
### Async Support
419419
420420
Retry4j has some built in support for executing and retrying on one or more threads in an asynchronous fashion. The
421-
`AsyncCallExecutor` utilizes threading and async mechanisms via Java's `ExecutorService` and `CompletableFuture`
422-
API's. A basic example of this in action with a single call:
421+
`AsyncCallExecutor` utilizes threading and async mechanisms via Java's `CompletableFuture` API. A basic example of this
422+
in action with a single call:
423423

424424
```java
425425
AsyncCallExecutor<Boolean> executor = new AsyncCallExecutor<>(config);
@@ -441,12 +441,12 @@ CompletableFuture<Status<Boolean>> future2 = executor.execute(callable2);
441441
CompletableFuture<Status<Boolean>> future3 = executor.execute(callable3);
442442

443443
CompletableFuture.allOf(future1, future2, future3).join();
444-
executor.getThreadExecutorService().shutdown();
445444
```
446445

447-
In both of these examples, the `AsyncCallExecutor` takes care of instantiating and using a simple, default
448-
`ExecutorService` for managing threads. If you wish to define what `ExecutorService` gets used by the
449-
`AsyncCallExecutor`, you can pass it in as part of the constructor like this:
446+
If you wish to define a thread pool to be used by your `AsyncCallExecutor`, you can define and pass in an
447+
`ExecutorService` in the constructor. When using this pattern, it's important to remember that this thread pool will not
448+
shut itself down and you will have to explicitly call `shutdown()` on the `ExecutorService` if you want it to be cleaned
449+
up.
450450
451451
```java
452452
ExecutorService executorService = Executors.newFixedThreadPool(10);
@@ -457,11 +457,6 @@ You can register retry listeners and configuration on an `AsyncCallExecutor` in
457457
synchronous `CallExecutor`. All calls in all threads that are triggered from an `AsyncCallExecutor` after its
458458
construction will use the same listeners and configuration.
459459
460-
It's important to note that a Java `ExecutorService` will not shut down automatically when there is no additional work to do. It will hang onto threads indefinitely until you shut it down. If you need a reference to the `ExecutorService` being used by you instance of `AsyncCallExecutor` you can use the `getThreadExecutorService()` method and then call `shutdown()` or `shutdownNow()`.
461-
462-
All of this async and threading functionality is new as of `0.9.0` and may need some time to settle before it is
463-
completely stable and mature.
464-
465460
### Logging
466461
467462
Retry4j contains detailed internal logging using [SLF4J](https://www.slf4j.org/manual.html). If you do not specify a SLF4J implementation, these logs will be discarded. If you do provide an implementation (eg: Logback, Log4J, etc) you can specify the log level on the `com.evanlennick.retry4j` package to set Retry4j logging to a specific level.

0 commit comments

Comments
 (0)