java: relationship of the Runnable and Thread interfaces
- by Karl Patrick
I realize that the method run() must be declared because its declared in the Runnable interface. But my question comes when this class runs how is the Thread object allowed if there is no import call to a particular package? how does runnable know anything about Thread or its methods? does the Runnable interface extend the Thread class? Obviously I don't understand interfaces very well. thanks in advance.
class PrimeFinder implements Runnable{
public long target;
public long prime;
public boolean finished = false;
public Thread runner;
PrimeFinder(long inTarget){
target = inTarget;
if(runner == null){
runner = new Thread(this);
runner.start()
}
}
public void run(){
}
}