This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

thread  RSS feed

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!