This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
 
jQuery in Action, 2nd edition
 
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