Class ScheduledTask

java.lang.Object
fr.hytale.loader.scheduler.ScheduledTask

public class ScheduledTask extends Object
Represents a scheduled task that can be cancelled.

This class wraps a ScheduledFuture and provides simplified methods to check status and cancel the task.

Since:
1.0.3
Version:
1.0.4
Author:
HytaleLoader
  • Constructor Details

    • ScheduledTask

      public ScheduledTask(ScheduledFuture<?> future)
      Creates a new ScheduledTask wrapper.
      Parameters:
      future - the underlying ScheduledFuture
  • Method Details

    • cancel

      public boolean cancel()
      Cancels this scheduled task.

      If the task has not yet started, it will be prevented from running. If the task is currently running, it may be interrupted.

      Returns:
      true if the task was cancelled, false if it was already completed or cancelled
    • cancelAndInterrupt

      public boolean cancelAndInterrupt()
      Cancels this scheduled task and attempts to interrupt if it's running.
      Returns:
      true if the task was cancelled, false if it was already completed or cancelled
    • isCancelled

      public boolean isCancelled()
      Checks if this task has been cancelled.
      Returns:
      true if the task was cancelled before completion
    • isDone

      public boolean isDone()
      Checks if this task has completed.

      Completion may be due to normal termination, an exception, or cancellation.

      Returns:
      true if the task completed
    • isActive

      public boolean isActive()
      Checks if this task is still running or scheduled to run.
      Returns:
      true if the task is active
    • getFuture

      public ScheduledFuture<?> getFuture()
      Gets the underlying ScheduledFuture.
      Returns:
      the wrapped ScheduledFuture