File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Master exam Thread question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Master exam Thread question" Watch "Master exam Thread question" New topic

Master exam Thread question

Biby Thoms
Ranch Hand

Joined: Jan 10, 2006
Posts: 48
I am always getting Stimpy 100 times for all excution.

But exam reference saying the output for the following question is Ren Ren Ren...Stimpy Stimpy Stimpy

Thanks<br />Biby Thoms
Zhu Ho

Joined: Aug 29, 2006
Posts: 1
The thread for InnerRun never start so it won't be run. So only InnerRunTwo is run.
Shailesh Kumar

Joined: Sep 04, 2006
Posts: 16
Are you sure if it wasn't like this?

InnerRun ir = new InnerRun();
Thread t = new Thread(ir);//ir is passed here in the constructor

May be a printing mistake.

"Expect the Unexpected!!"<br /> <br />SCJP5,SCMAD
Dave Reinhardt
Ranch Hand

Joined: Aug 07, 2006
Posts: 54
Unless this is a possible answer, I think there is a bug in the following code sample:

void start() {
InnerRun ir = new InnerRun();
Thread t = new Thread(ir); //wasn't passed the runnable ir
InnerRunTwo irr = new InnerRunTwo(t);
Thread uu = new Thread(irr);

If you make this change then you will get 100 Ren and then 100 Stimpy. As it was in the original code, the thead t wasn't given a job(a runnable) to do.
Biby Thoms
Ranch Hand

Joined: Jan 10, 2006
Posts: 48
You are correct Shail...Good catch. Thank you all
I agree. Here's the link:
subject: Master exam Thread question
jQuery in Action, 3rd edition