aspose file tools*
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Master exam Thread question" Watch "Master exam Thread question" New topic
Author

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
Greenhorn

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
Greenhorn

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);
t.start();
uu.start();
}

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: http://aspose.com/file-tools
 
subject: Master exam Thread question