aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "thread" Watch "thread" New topic
Author

thread

Hasitha Randika
Ranch Hand

Joined: Sep 04, 2007
Posts: 50
class A extends Thread{
public void main(){
System.out.println("A");
}
A(Runnable r){
super(r);
}
A(){

}
}
class B implements Runnable{
public void run(){
System.out.println("B");
}
}
class C{
public static void main(String ar[]){
A a = new A();
B b = new B();
Thread t =new Thread();
a.start();
b.start();// this is a compilation error //line 1
t.start();
}
}
in the above code syntax line 1 gives a compile error why's that?
do i have to use a construcor if i implement the runnable interface
Vas Golla
Greenhorn

Joined: Aug 09, 2007
Posts: 8
new Thread(b).start();
will work if used Runnable.
You tried to call start() on a Runnable where as start() is to be from a Thread.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: thread