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();
}
}