| | |
| | | public abstract class BackgroundTask<T> |
| | | { |
| | | private BackgroundTaskThread<T> taskThread; |
| | | private boolean interrupted; |
| | | /** |
| | | * Creates a new thread and begins running the task in the background. When |
| | | * the task has completed, the {@code backgroundTaskCompleted} method will be |
| | |
| | | */ |
| | | public final void startBackgroundTask() |
| | | { |
| | | interrupted = false; |
| | | taskThread = new BackgroundTaskThread<T>(this); |
| | | taskThread.start(); |
| | | } |
| | |
| | | */ |
| | | public final void interrupt() |
| | | { |
| | | interrupted = true; |
| | | if (taskThread != null) |
| | | { |
| | | taskThread.interrupt(); |
| | |
| | | */ |
| | | public boolean isInterrupted() |
| | | { |
| | | if (taskThread != null) |
| | | { |
| | | return taskThread.isInterrupted(); |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | return interrupted; |
| | | } |
| | | |
| | | /** |