My program -
class RunnableA implements Runnable{
public void run(){
System.out.println("Program A");
}
}
class MyThread extends Thread{
}
class Demo{
public static void main(String args[]){
RunnableA a1=new RunnableA();
a1.start();
}
}
And I got this when compiling.
Demo.java:12: error: cannot find symbol
start
is a method of Thread
class, not a method of the Runnable interface.
Here's a way to start a Thread
that would run your Runnable's logic :
class Demo {
public static void main(String args[]){
RunnableA a1=new RunnableA();
new Thread(a1).start();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.