Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
0.14.0
-
None
Description
The current code simply uses
new Thread(this).start()
This precludes the user from configuring the thread's attributes - name, priority, stack size, thread-group and most important whether it is a daemon or not. By allowing to provide an ExecutorService we enable all these.
Note: the choice for using an ExecutorService rather than a simple(r) Executor is twofold:
- The documentation for Executor#execute() clearly states:
Executes the given command at some time in the future. The command may execute in a new thread, in a pooled thread, or in the calling thread, at the discretion of the Executor implementation.
In our case we want to make sure that a new thread is spawned - The ExecutorService#submit() call returns a Future object which we can later use to stop the command when the destroy() method is called