• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

thread

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic