About Question enthuware.ocpjp.v7.2.1291 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
homeric
Posts: 6
Joined: Sun Mar 13, 2016 1:34 am
Contact:

About Question enthuware.ocpjp.v7.2.1291 :

Post by homeric »

I did not understand why it executes Pooler's run(). A new Threader() is passed to Pooler's run(Runnable r). Then super(r) calls run() of Thread class that executes Runnable's run(). Since Runnable r contains Threader object it should be printing 'In threader'.

Where am I going wrong?

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1291 :

Post by admin »

Why do you think "then super(r) calls run() of Thread class"?
If you like our products and services, please help us by posting your review here.

homeric
Posts: 6
Joined: Sun Mar 13, 2016 1:34 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1291 :

Post by homeric »

Pooler extends Thread so call to super(r) will execute run(Runnable) of Thread.

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1291 :

Post by admin »

Again, why do you think that super(r) will execute run(Runnable) at all? Thread's run is called when you start a thread, not when you create a thread.
If you like our products and services, please help us by posting your review here.

homeric
Posts: 6
Joined: Sun Mar 13, 2016 1:34 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1291 :

Post by homeric »

I got it now. Will h.start() call Pooler's run() method directly because h has been assigned a Pooler object?

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1291 :

Post by admin »

That is correct. But go through the explanation again for more clarity.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 55 guests