• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Compile Error : cannot find symbol constructor Thread(Runnable)

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Would you give me some adivce to solve this compiling error?
Thread class has a constructor which has argument Runnable class.
I can't understand why this happen.

=================================================================
RunnableTest.java:21: cannot find symbol
symbol : constructor Thread(RunnableTest)
location: class java.lang.Thread
new Thread(thread50).start();
^
RunnableTest.java:22: cannot find symbol
symbol : constructor Thread(RunnableTest)
location: class java.lang.Thread
new Thread(thread100).start();
^
2 errors
======================================================
/* RunnableTest.java */
import java.io.*;
class RunnableTest implements Runnable {
long delay;
String message;
RunnableTest(String message, long delay) {
this.message = message;
this.delay = delay;
}
public void run() {
try {
while(true) {
System.out.print(message+ " ");
Thread.sleep(delay);
}
} catch(InterruptedException e){ return; }
}
public static void main(String[] args) {
RunnableTest thread50 = new RunnableTest("t50", 50);
RunnableTest thread100 = new RunnableTest("t100", 100);
new Thread(thread50).start();
new Thread(thread100).start();
}
}
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Compiled fine on my system without any errors. The code seems fine.
 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's strange. It compiles fine for me. Are you sure you don't have a second copy of RunnableTest.java in your working directory, one that doesn't implement the Runnable interface?
 
Junghyun Cho
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems it's my computer problem. I tried on other PC and it works.

I don't know why but only calling java.lang.Thread costructor make compiling error happen.
Anyone knowing about this?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Most likely in your experimentation you created your own class named "Thread" or interface named "Runnable", and either the *.java or *.class files are still around on that machine. Use the Windows "Find File" feature to find Thread.java, Thread.class, Runnable.java and/or Runnable.class, and delete any ones you find that you may have created yourself.
 
Junghyun Cho
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found there was Runnable.class in my classpath directory.
After deleting that file, it works.

Thank you , Ernest and all who replied.
 
reply
    Bookmark Topic Watch Topic
  • New Topic