de.grogra.task
Class SolverInOwnThread

java.lang.Object
  extended by de.grogra.task.Solver
      extended by de.grogra.task.SolverInOwnThread
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
LocalSolver

public abstract class SolverInOwnThread
extends Solver
implements java.lang.Runnable

This abstract class implements Solver such that a thread is created in which the actual work is done.

Author:
Ole Kniemeyer

Constructor Summary
SolverInOwnThread()
           
 
Method Summary
protected abstract  java.lang.Thread createThread()
          Create the thread to use.
 void dispose()
          This method is invoked by the Task when this solver is removed from the task.
 void run()
           
protected  void solve()
          This method has to be implemented by subclasses in order to solve the current partial task synchronously or asynchronously.
protected abstract  void solveImpl(PartialTask task)
          This method has to be implemented to perform the actual work.
 
Methods inherited from class de.grogra.task.Solver
getCurrentPartialTask, getTask, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SolverInOwnThread

public SolverInOwnThread()
Method Detail

createThread

protected abstract java.lang.Thread createThread()
Create the thread to use. If this returns null, the solve methods operates synchronously, i.e., it immediately solves the partial task.

Returns:
thread to use for operation, or null in synchronous case

dispose

public void dispose()
Description copied from class: Solver
This method is invoked by the Task when this solver is removed from the task. Subclasses have to implement this method in order to free resources (e.g., created threads).

Specified by:
dispose in class Solver

run

public void run()
Specified by:
run in interface java.lang.Runnable

solve

protected void solve()
Description copied from class: Solver
This method has to be implemented by subclasses in order to solve the current partial task synchronously or asynchronously. After the partial task has been solved, the method Task.partialTaskDone(Solver) has to be invoked.

Specified by:
solve in class Solver

solveImpl

protected abstract void solveImpl(PartialTask task)
This method has to be implemented to perform the actual work.

Parameters:
task - task to solve