File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java threads

 
Asanka Vithanage
Ranch Hand
Posts: 59
  • 0
  • 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: 9496
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you
ankit
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic