File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread Doubts

 
Micheal John
Ranch Hand
Posts: 344
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From web page


How the output is a? pls expalain
 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are creating an A object, and calling it's start() method -- which in turns calls the run() method. This run() method prints the "A".

The A method does set the runnable of the object to B, but since you overridden the run() method of A, it doesn't call it anymore.

Henry
 
Ignacio Cavero
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are using the new A(Thread t) constructor for A that it is inheriting from the Thread class. Because of that, without noticing you are starting the run method of the runable Object B instead of the run method of A.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic