[SSHD-835] Improve readme
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/64464997 Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/64464997 Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/64464997 Branch: refs/heads/master Commit: 644649975c3ef28c544c34caba7fd77d3cd85e6b Parents: ce29eab Author: Guillaume Nodet <gno...@apache.org> Authored: Thu Jul 26 05:14:30 2018 +0200 Committer: Guillaume Nodet <gno...@apache.org> Committed: Thu Jul 26 05:14:30 2018 +0200 ---------------------------------------------------------------------- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/64464997/README.md ---------------------------------------------------------------------- diff --git a/README.md b/README.md index cb04e3f..b718b16 100644 --- a/README.md +++ b/README.md @@ -410,9 +410,10 @@ be tailored to present different views for different clients The framework requires from time to time spawning some threads in order to function correctly - e.g., commands, SFTP subsystem, port forwarding (among others) require such support. By default, the framework will allocate an [ExecutorService](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html) for each specific purpose and then shut it down when the module has completed its work - e.g., session -was closed. Users may provide their own `ExecutorService`(s) instead of the internally auto-allocated ones - e.g., in -order to control the max. spawned threads, stack size, track threads, etc... If this is done, then one must also provide -the `shutdownOnExit` value indicating to the overridden module whether to shut down the service once it is no longer necessary. +was closed. Note that SSHD uses the `CloseableExecutorService` interface instead of the usual `ExecutorService` in order to provide graceful shutdown. +Users may provide their own `CloseableExecutorService`(s) instead of the internally auto-allocated ones - e.g., in +order to control the max. spawned threads, stack size, track threads, etc... but they can leverage the `ThreadUtils.ThreadPoolExecutor` implementation which should cover most use cases. +If a single executor is shared between several services, it needs to be wrapped with the `ThreadUtils.noClose(executor)` method. ```java @@ -423,8 +424,7 @@ the `shutdownOnExit` value indicating to the overridden module whether to shut d * it down when the command is destroyed */ SftpSubsystemFactory factory = new SftpSubsystemFactory.Builder() - .withExecutorService(mySuperDuperExecutorService) - .withShutdownOnExit(false) // I will take care of shutting it down + .withExecutorService(ThreadUtils.noClose(mySuperDuperExecutorService)) .build(); SshServer sshd = SshServer.setupDefaultServer(); sshd.setSubsystemFactories(Collections.<NamedFactory<Command>>singletonList(factory));