DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Thread error

  1. #1
    Join Date
    Mar 2003

    Thread error

    I keep getting an error with the thread constructor in java. Here's the basic of what I have in the 'faulty' program.

    import java.awt.*;
    import java.net.*;
    import java.applet.*

    public class WordSearch extends Applet{

    Thread th;

    public void init() {

    public void start(){
    th = new Thread (this);

    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.

  2. #2
    Join Date
    Feb 2004
    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..
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

  3. #3
    Join Date
    Mar 2003
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.