Code:
class A implements Runnable{
public void run(){
System.out.println("run");
}
public static void main(String[]args){
A a=new A();
Thread t=new Thread(a); // this is where the error occurs
t.start();
}
}
|
Newbie Member
|
|
| 9Jan2010,13:50 | #1 |
|
when implementing runnable i cant pass a runnable to a Thread.
Code:
class A implements Runnable{
public void run(){
System.out.println("run");
}
public static void main(String[]args){
A a=new A();
Thread t=new Thread(a); // this is where the error occurs
t.start();
}
}
|
|
Newbie Member
|
|
| 9Jan2010,13:54 | #2 |
|
the error end up getting is "cannot find symbol constructor Thread(A)".when i extend Thread it works fine.and if i leave the thread constructor empty(not passing a runnable)it compiles.
|
|
Go4Expert Member
|
|
| 16Feb2010,16:43 | #3 |
|
Hi.
I put it all in a java file called A.java and it works as expected? What IDE / Development environment are you using? Best regards Ewald |