This class changes the behavior of how listeners are called from the parent class
RunnableListenerHelper. In this implementation when listeners are invoked with the
#callListeners() function, the invocation of all the listeners will occur on the
Executor that was provided at construction. If the listener was added without a
provided executor it will then run on the provided executor (in the thread doing the
#callListeners() invocation, AKA it will run that listener before executing other
listeners). If the listener was added with a provided executor, that listener will still
execute on the provided executor (so not necessarily the executor provided at construction
time).
If it is desired that all listeners are executed asynchronously from each other, you should
actually use the normal
RunnableListenerHelper, and instead just ensure that an
executor is provided when each listener is added. If you want listeners to execute
concurrently from each other, but not concurrently for any single listener,
DefaultExecutorRunnableListenerHelper is likely a better choice. This class is only
designed to ensure that
#callListeners() invocations will never block.
To better clarify when this implementation makes sense compared to
RunnableListenerHelper and
DefaultExecutorRunnableListenerHelper. If you have
a LOT of quick running listeners, this is the right class for you. If you have few listeners
that execute quickly, then the normal
RunnableListenerHelper is likely a better choice.
If you have long running/complex listeners,
DefaultExecutorRunnableListenerHelper is
possibly the better choice. Alternative for the last condition you could use the normal
RunnableListenerHelper, and just ensure that an executor is provided for every listener
(but if you want to ensure a given listener is not executed concurrently the
DefaultExecutorRunnableListenerHelper will handle this for you).