- java.lang.Object
-
- javax.enterprise.concurrent.ManagedExecutors
-
public class ManagedExecutors extends Object
Utility methods for classes defined in this package.- Since:
- 1.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static boolean
isCurrentThreadShutdown()
Utility method for checking theisShutdown()
value of the current thread if it is aManageableThread
created fromManagedThreadFactory.newThread()
.static <V> Callable<V>
managedTask(Callable<V> task, ManagedTaskListener taskListener)
Returns aCallable
object that also implementsManagedTask
interface so it can receive notification of lifecycle events with the providedManagedTaskListener
when the task is submitted to aManagedExecutorService
or aManagedScheduledExecutorService
.static <V> Callable<V>
managedTask(Callable<V> task, Map<String,String> executionProperties, ManagedTaskListener taskListener)
Returns aCallable
object that also implementsManagedTask
interface so it can receive notification of lifecycle events with the providedManagedTaskListener
and to provide additional execution properties when the task is submitted to aManagedExecutorService
or aManagedScheduledExecutorService
.static Runnable
managedTask(Runnable task, ManagedTaskListener taskListener)
Returns aRunnable
object that also implementsManagedTask
interface so it can receive notification of lifecycle events with the providedManagedTaskListener
when the task is submitted to aManagedExecutorService
or aManagedScheduledExecutorService
.static Runnable
managedTask(Runnable task, Map<String,String> executionProperties, ManagedTaskListener taskListener)
Returns aRunnable
object that also implementsManagedTask
interface so it can receive notification of lifecycle events with the providedManagedTaskListener
and to provide additional execution properties when the task is submitted to aManagedExecutorService
or aManagedScheduledExecutorService
.
-
-
-
Method Detail
-
isCurrentThreadShutdown
public static boolean isCurrentThreadShutdown()
Utility method for checking theisShutdown()
value of the current thread if it is aManageableThread
created fromManagedThreadFactory.newThread()
.- Returns:
- Returns the
isShutdown()
value if the current thread is aManageableThread
created byManagedThreadFactory
, or false if the current thread is not aManageableThread
.
-
managedTask
public static Runnable managedTask(Runnable task, ManagedTaskListener taskListener) throws IllegalArgumentException
Returns aRunnable
object that also implementsManagedTask
interface so it can receive notification of lifecycle events with the providedManagedTaskListener
when the task is submitted to aManagedExecutorService
or aManagedScheduledExecutorService
.Example:
Runnable task = ...; ManagedTaskListener myTaskListener = ...; ManagedExecutorService executor = ...; Runnable taskWithListener = ManagedExecutors.managedTask(task, myTaskListener); executor.submit(taskWithListener);
- Parameters:
task
- the task to have the given ManagedTaskListener associated withtaskListener
- (optional) theManagedTaskListener
to receive lifecycle events notification when the task is submitted. Iftask
implementsManagedTask
, andtaskListener
is notnull
, theManagedTaskListener
interface methods of the task will not be called.- Returns:
- a Runnable object
- Throws:
IllegalArgumentException
- iftask
isnull
-
managedTask
public static Runnable managedTask(Runnable task, Map<String,String> executionProperties, ManagedTaskListener taskListener) throws IllegalArgumentException
Returns aRunnable
object that also implementsManagedTask
interface so it can receive notification of lifecycle events with the providedManagedTaskListener
and to provide additional execution properties when the task is submitted to aManagedExecutorService
or aManagedScheduledExecutorService
.- Parameters:
task
- the task to have the given ManagedTaskListener associated withtaskListener
- (optional) theManagedTaskListener
to receive lifecycle events notification when the task is submitted. Iftask
implementsManagedTask
, andtaskListener
is notnull
, theManagedTaskListener
interface methods of the task will not be called.executionProperties
- (optional) execution properties to provide additional hints toManagedExecutorService
orManagedScheduledExecutorService
when the task is submitted. Iftask
implementsManagedTask
with non-empty execution properties, theRunnable
returned will contain the union of the execution properties specified in thetask
and theexecutionProperties
argument, with the latter taking precedence if the same property key is specified in both. After the method is called, further changes to theMap
object will not be reflected in theRunnable
returned by this method.- Returns:
- a Runnable object
- Throws:
IllegalArgumentException
- iftask
isnull
-
managedTask
public static <V> Callable<V> managedTask(Callable<V> task, ManagedTaskListener taskListener) throws IllegalArgumentException
Returns aCallable
object that also implementsManagedTask
interface so it can receive notification of lifecycle events with the providedManagedTaskListener
when the task is submitted to aManagedExecutorService
or aManagedScheduledExecutorService
.- Parameters:
task
- the task to have the given ManagedTaskListener associated withtaskListener
- (optional) theManagedTaskListener
to receive lifecycle events notification when the task is submitted. Iftask
implementsManagedTask
, andtaskListener
is notnull
, theManagedTaskListener
interface methods of the task will not be called.- Returns:
- a Callable object
- Throws:
IllegalArgumentException
- iftask
isnull
-
managedTask
public static <V> Callable<V> managedTask(Callable<V> task, Map<String,String> executionProperties, ManagedTaskListener taskListener) throws IllegalArgumentException
Returns aCallable
object that also implementsManagedTask
interface so it can receive notification of lifecycle events with the providedManagedTaskListener
and to provide additional execution properties when the task is submitted to aManagedExecutorService
or aManagedScheduledExecutorService
.- Parameters:
task
- the task to have the given ManagedTaskListener associated withtaskListener
- (optional) theManagedTaskListener
to receive lifecycle events notification when the task is submitted. Iftask
implementsManagedTask
, andtaskListener
is notnull
, theManagedTaskListener
interface methods of the task will not be called.executionProperties
- (optional) execution properties to provide additional hints toManagedExecutorService
orManagedScheduledExecutorService
when the task is submitted. Iftask
implementsManagedTask
with non-empty execution properties, theRunnable
returned will contain the union of the execution properties specified in thetask
and theexecutionProperties
argument, with the latter taking precedence if the same property key is specified in both. After the method is called, further changes to theMap
object will not be reflected in theCallable
returned by this method.- Returns:
- a Callable object
- Throws:
IllegalArgumentException
- iftask
isnull
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 18/08/2025
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-javaee-rf-javax/enterprise/concurrent/managedexecutors.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.