Package com.jackmeng.core.util
Class use_HideousTask<T>
java.lang.Object
com.jackmeng.core.util.use_HideousTask<T>
- All Implemented Interfaces:
impl_Identifiable
,Serializable
,Runnable
public final class use_HideousTask<T>
extends Object
implements Runnable, Serializable, impl_Identifiable
A hideous thread that kills running threads when a new task is submitted.
How this task runner works:
- Submit a task
- The old task (if there is) is abandoned/dropped and the current submission is run. The old task does not receive any compensations.
- The current submission runs asynchronously and outside dependent tasks waiting for the result can either wait or be alerted later for when the task is done
- Once the current submission finishes, the task runner destroys the
submission and returns to a dormant state. To force a destruction of the
runner to either remove it from memory or from use, call the
destroy()
method. - At any point in time when the currentTask is finished, the result is
stored in overwritable variable
and can be accessed using
get()
.
run()
simply tries to run the currentTask if it has not been
killed yet.
This object should be reused for similar tasks.
THIS SHOULD NOT BE USED FOR ANY DIRECT GRAPHICS2D API RELATED OPERATIONS!!!
REMEMBER JAVA SWING IS NOT THREAD SAFE.- Author:
- Jack Meng
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
-
Field Details
-
myName
-
curr
-
res
-
running
-
currentTask
-
-
Constructor Details
-
use_HideousTask
-
-
Method Details
-
destroy
public void destroy() -
shakedown
public void shakedown()Resets everything in this task manager -
is_processing
public boolean is_processing() -
get
-
gentle_push
-
push
Forcefully push the currentTask off a cliff and place the submission and make it run. No compensation for the old task's listeners and handlers: they simply will not be notified of what happened. The current task is automatically started for execution. If you do not want execution to begin right away, you may usegentle_push(Callable)
which only kills and sets up the current task to be ran later.- Parameters:
task
- The current submission
-
id
- Specified by:
id
in interfaceimpl_Identifiable
-
toString
-
run
public void run()
-