Package org.jtrim2.ui.concurrent
Interface UiExecutorProvider
public interface UiExecutorProvider
Defines a factory for executors scheduling events on the UI thread of the
underlying UI framework (such as Swing or Java FX).
Thread safety
The methods of this interface are expected to be safely accessible from multiple threads concurrently.Synchronization transparency
The methods of this interface are required to be synchronization transparent.-
Method Summary
Modifier and TypeMethodDescriptiongetSimpleExecutor(boolean alwaysExecuteLater) Returns aTaskExecutorwhich executes tasks submitted to them on the UI thread of the associated UI framework.getStrictExecutor(boolean alwaysExecuteLater) Returns aTaskExecutorwhich executes tasks submitted to them on the UI thread of the associated UI framework.
-
Method Details
-
getSimpleExecutor
Returns aTaskExecutorwhich executes tasks submitted to them on the UI thread of the associated UI framework. The returned executor does not necessarily executes tasks in the same order as the tasks were submitted. In case tasks needed to be executed in the same order as they were submitted to the executor: Use thegetStrictExecutor(boolean)method.- Parameters:
alwaysExecuteLater- if this argument istrue, submitted tasks are never executed synchronously on the calling thread (i.e.: if the calling thread is the UI thread, the framework must execute the scheduled task later). In case this argument isfalse, tasks submitted from an UI thread will be executed immediately on the calling thread.- Returns:
- a
TaskExecutorwhich executes tasks submitted to them on the UI thread of the associated UI framework. This method never returnsnull.
-
getStrictExecutor
Returns aTaskExecutorwhich executes tasks submitted to them on the UI thread of the associated UI framework. The returned executor executes tasks in the same order as the tasks were submitted. If you don't need to execute them in the same order, consider using thegetSimpleExecutor(boolean)method.The returned executor is more efficient than an instance of
SwingTaskExecutor.- Parameters:
alwaysExecuteLater- if this argument istrue, submitted tasks are never executed synchronously on the calling thread (i.e.: if the calling thread is the UI thread, the framework must execute the scheduled task later). In case this argument isfalse, tasks submitted from the UI thread will be executed immediately on the calling thread (this may not always possible to execute tasks in the order they were submitted).- Returns:
- a
TaskExecutorwhich executes tasks submitted to them on the UI thread of the associated UI framework. This method never returnsnull.
-