Can someone explain this java interface to me please?
Posted
by Karl Patrick
on Stack Overflow
See other posts from Stack Overflow
or by Karl Patrick
Published on 2010-03-09T00:59:32Z
Indexed on
2010/03/09
1:06 UTC
Read the original article
Hit count: 227
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 dont 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(){
}
}
© Stack Overflow or respective owner