Schnittstelle LongTask

Alle Superschnittstellen:
Future<Long>, Runnable, RunnableFuture<Long>
Alle bekannten Implementierungsklassen:
LongAsyncBuilder.BaseLongTask

public interface LongTask extends RunnableFuture<Long>
A Type Specific Task interface that allows you to keep track of the task that is currently running.
It extends Runnable future and supports said functions but also provides quality of life functions like:
- isSuccesfull: which allows to detect if the task was completed properly and not interrupted or crashed. - pause/resume: which allows to pause/resume the task at any moment, making it easier to create thread-safe actions.
  • Verschachtelte Klassen - Übersicht

    Von Schnittstelle geerbte verschachtelte Klassen/Schnittstellen java.util.concurrent.Future

    Future.State
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    void
    Pauses the task, which lets the thread finish without completing the task.
    default Long
    get()
    Veraltet.
    default Long
    get(long timeout, TimeUnit unit)
    Veraltet.
    long
    A Type Specific get method that allows to reduce (un)boxing of primtives.
    long
    getLong(long timeout, TimeUnit unit)
    Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.
    boolean
    Helper function to detect if the task is currently paused.
    boolean
    Quality of life function that allows to detect if no cancellation/exception was applied to this task and it completed on its own.
    void
    Pauses the task, which lets the thread finish without completing the task.
    void
    Continues the task if it wasn't already completed.

    Von Schnittstelle geerbte Methoden java.util.concurrent.Future

    cancel, exceptionNow, isCancelled, isDone, resultNow, state

    Von Schnittstelle geerbte Methoden java.util.concurrent.RunnableFuture

    run
  • Methodendetails

    • isPaused

      boolean isPaused()
      Helper function to detect if the task is currently paused.
      Gibt zurück:
      true if paused
    • pause

      void pause()
      Pauses the task, which lets the thread finish without completing the task. Tasks are written in the way where they can pause without any issues. This won't be instant, as this function is applied asynchronous and doesn't check if the thread paused. So make sure it had the time to pause.
    • awaitPausing

      void awaitPausing()
      Pauses the task, which lets the thread finish without completing the task. Tasks are written in the way where they can pause without any issues. This won't be instant, as this function is applied asynchronous. It will await the pausing of the task.
    • resume

      void resume()
      Continues the task if it wasn't already completed. This is done by resubmitting the task to the executor provided.
    • isSuccessful

      boolean isSuccessful()
      Quality of life function that allows to detect if no cancellation/exception was applied to this task and it completed on its own.
      Gibt zurück:
      true if it was properly completed
    • getLong

      A Type Specific get method that allows to reduce (un)boxing of primtives. Waits if necessary for the computation to complete, and then retrieves its result.
      Gibt zurück:
      the computed result as primitive
      Löst aus:
      CancellationException - if the computation was cancelled
      ExecutionException - if the computation threw an exception
      InterruptedException - if the current thread was interrupted while waiting
    • getLong

      long getLong(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
      Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.
      Parameter:
      timeout - the maximum time to wait
      unit - the time unit of the timeout argument
      Gibt zurück:
      the computed result as primitive
      Löst aus:
      CancellationException - if the computation was cancelled
      ExecutionException - if the computation threw an exception
      InterruptedException - if the current thread was interrupted while waiting
      TimeoutException - if the wait timed out
    • get

      Veraltet.
      Angegeben von:
      get in Schnittstelle Future<Long>
      Löst aus:
      InterruptedException
      ExecutionException
    • get

      Veraltet.
      Angegeben von:
      get in Schnittstelle Future<Long>
      Löst aus:
      InterruptedException
      ExecutionException
      TimeoutException