This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes mysterious Mr. Thread(), Mr. run() and Mr. start() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "mysterious Mr. Thread(), Mr. run() and Mr. start()" Watch "mysterious Mr. Thread(), Mr. run() and Mr. start()" New topic
Author

mysterious Mr. Thread(), Mr. run() and Mr. start()

Marcus Deviln
Ranch Hand

Joined: Jan 29, 2009
Posts: 39

...and the answer:

(d) The program will compile without errors and will print out |R1b| once and |R2| twice, in some order, every time the program is run.

Why does "|R2|" print if it doesn't have a run() method? or better yet why does it not need its own run() method for it to print out? Why will "|R2|" print out twice? The author says it will print out in some order- which makes me wonder how is it that it can print in random order? I thought the constructors will be used as they appear from the top down like an instance initializer block.


+Deviln+ The power of JAVA compels you!
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18917
    
  40

http://faq.javaranch.com/java/QuoteYourSources


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Jim Hoglund
Ranch Hand

Joined: Jan 09, 2008
Posts: 525
There are some typos and where is R2 defined?
Can you clean up your code a bit? Thanks.
Jim ... ...


BEE MBA PMP SCJP-6
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1712
    
  12

1. You still haven't quoted your source. Please do so.
2. There's a compiler error on line 10


When you do things right, people won't be sure you've done anything at all.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: mysterious Mr. Thread(), Mr. run() and Mr. start()