This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: thread
 
Similar Threads
Thread target
Thread Question
When both Thread and Runnable have public void run
regarding threads
Thread made out of Thread