File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes dont call them threads..they are hard to break:) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "dont call them threads..they are hard to break:)" Watch "dont call them threads..they are hard to break:)" New topic
Author

dont call them threads..they are hard to break:)

Harvinder Singh
Ranch Hand

Joined: Feb 14, 2003
Posts: 90
Tuesday,2/17/2004 10:57:45 PM
Hi,
May I know why the second thread prints A and not B?
Let me make a wild guess first.When I pass a runnable instance to the thread class it is registered with the Thread scheduler but when I pass to the subclass of A it is not.


Hard work beats talent<br />when talent doesn't work hard.<p> - Tim Notke
Richard Quist
Ranch Hand

Joined: Feb 18, 2004
Posts: 96
Originally posted by Harvinder Singh:
Tuesday,2/17/2004 10:57:45 PM
Hi,
May I know why the second thread prints A and not B?
Let me make a wild guess first.When I pass a runnable instance to the thread class it is registered with the Thread scheduler but when I pass to the subclass of A it is not.


The A.run() method overrides the Thread.run()....add a call to super.run() before or after your System.out.print("A"); statement


Rich
SCJP 1.4
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: dont call them threads..they are hard to break:)
 
Similar Threads
Which run() method will run?
question of threads from Dan's mock
Thread
On Threads From Dan Chisholm's mock
Threads question from Dan's Topic Exam 4