Class TaskGroup

  • All Implemented Interfaces:
    java.lang.Iterable<Task<?>>, Group<Task<?>>

    public class TaskGroup
    extends Task<java.lang.Void>
    implements Group<Task<?>>, java.lang.Iterable<Task<?>>
    Task that runs a group of tasks in parallel and notifies listeners when all tasks are complete.
    • Constructor Detail

      • TaskGroup

        public TaskGroup()
      • TaskGroup

        public TaskGroup​(java.util.concurrent.ExecutorService executorService)
    • Method Detail

      • execute

        public java.lang.Void execute()
                               throws TaskExecutionException
        Description copied from class: Task
        Synchronously executes the task.
        Specified by:
        execute in class Task<java.lang.Void>
        Returns:
        The result of the task's execution.
        Throws:
        TaskExecutionException - If an error occurs while executing the task.
      • abort

        public void abort()
        Aborts all tasks in this group.
        Overrides:
        abort in class Task<java.lang.Void>
      • add

        public boolean add​(Task<?> element)
        Description copied from interface: Group
        Adds an element to the group.
        Specified by:
        add in interface Group<Task<?>>
        Parameters:
        element - The element to add to the group.
        Returns:
        true if the element was added to the group; false, otherwise.
      • remove

        public boolean remove​(Task<?> element)
        Description copied from interface: Group
        Removes an element from the group.
        Specified by:
        remove in interface Group<Task<?>>
        Parameters:
        element - The element to remove from the set.
        Returns:
        true if the element was removed from the group; false, otherwise.
      • contains

        public boolean contains​(Task<?> element)
        Description copied from interface: Group
        Tests the existence of an element in the group.
        Specified by:
        contains in interface Group<Task<?>>
        Parameters:
        element - The element whose presence in the group is to be tested.
        Returns:
        true if the element exists in the group; false, otherwise.
      • getCount

        public int getCount()
      • iterator

        public java.util.Iterator<Task<?>> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<Task<?>>