• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java threads

 
Asanka Vithanage
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i compiled this gives a asanswer
but my answer is 2.so can any body give a reson to this out


class B extends Thread{
public void run(){
System.out.println("1");
}
}

class A extends B implements Runnable {
public void Run(){
System.out.println("2");
}

public static void main( String as[]){

A a =new A();
Thread z=new Thread(a);
z.start();


}
}
 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi asanka!

In your code the run method in class A is mistyped. It must be run not Run. This is why you are getting wrong output...
 
Asanka Vithanage
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you
ankit
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic