public void start(){
th = new Thread (this);
th.start();
}
public void run(){
}
public void paint(Graphics g){
}
}
and....for some odd reason...here is the error I get.
WordSearch/WordSearch.java [13:1] cannot resolve symbol
symbol : constructor Thread (WordSearch)
location: class java.lang.Thread
th = new Thread (this);
^
1 error
Errors compiling WordSearch.
Does anyone know why its doing this? A similar error I've had before, without changing anything, had something to do with APIs and compiling with -deprecation.
05-14-2004, 11:47 AM
cjard
the Thread class cannot take an object of type WordSearch into any of its constructors... It's an oddly-worded error message, but it is not an odd message.
Thread has a constructor that takes Runnable objects, and to PROVE to the compiler that your WordSearch is capable if behaving like a Runnable, it MUST "implements Runnable"
Runnable mandates that a run() method be provided, which you have indeed done.. but it isnt enough that you just write void run(){}.. See what i mean?
|Its a bit like being pulled over by a cop, and he says "show me your license" and you say "well i dont have it with me but i can drive, obviously, because im sitting in the car, piloting it down the road"
and ihe's like "i dont care, if you dont have your license, i cannot accept anything else as proof that you can drive a car"
the compiler is saying "if you cannot implements Runnable, i cannot accept anything else as proof that this object is capable of existing in its own thread..
-
hope that helps..
05-14-2004, 12:07 PM
bleepblop
yeah, thanks!
I just added the 'implements Runnable', which I accidently overlooked when copying elements from a program, and it stopped the error and run.