Package com.jk.core.timer
Class JKTask
java.lang.Object
com.jk.core.timer.JKTask
- All Implemented Interfaces:
Runnable
This class is used for defining tasks that can be executed asynchronously.
- Version:
- 1.0
- Author:
- Dr. Jalal H. Kiswani
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
execute()
The method that gets executed when the task is run.getName()
This method retrieves the name of the task class.boolean
isDone()
This method checks if the task has been completed.void
run()
This method runs the task by invoking the execute method and marking the task as done.void
stop()
This method stops the execution of the task.
-
Constructor Details
-
JKTask
public JKTask()
-
-
Method Details
-
run
public void run()This method runs the task by invoking the execute method and marking the task as done. -
execute
protected abstract void execute()The method that gets executed when the task is run.Subclasses must implement this method to provide task-specific logic.
-
isDone
public boolean isDone()This method checks if the task has been completed.- Returns:
- true, if the task has been completed, false otherwise.
-
stop
public void stop()This method stops the execution of the task.This method sets the done flag to true and may perform additional cleanup.
-
getName
This method retrieves the name of the task class.- Returns:
- the name of the class implementing the task.
-