Interface ITaskManager

  • All Known Implementing Classes:
    TaskManager

    public interface ITaskManager
    This class uses Java scheduler (ScheduledFuture) to manage your tasks. The scheduler is used to schedule a thread or task that executes at a certain period of time or periodically at a fixed interval. It's useful when you want to create a time counter before starting a match or send messages periodically for one player.
    Author:
    kong
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void clear()
      Kill or stop all running tasks.
      void create​(java.lang.String id, java.util.concurrent.ScheduledFuture<?> task)
      Create a new task.
      int getRemainTime​(java.lang.String id)
      Retrieve the remain time of one task.
      void kill​(java.lang.String id)
      Kill or stop a running task.
    • Method Detail

      • create

        void create​(java.lang.String id,
                    java.util.concurrent.ScheduledFuture<?> task)
        Create a new task.
        Parameters:
        id - the unique id for management
        task - the running task, see ScheduledFuture
      • kill

        void kill​(java.lang.String id)
        Kill or stop a running task.
        Parameters:
        id - the unique id
      • clear

        void clear()
        Kill or stop all running tasks.
      • getRemainTime

        int getRemainTime​(java.lang.String id)
        Retrieve the remain time of one task.
        Parameters:
        id - the unique for retrieving the desired task
        Returns:
        the left time