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?
About Question enthuware.ocpjp.v7.2.1291 :
Moderator: admin
-
- Posts: 6
- Joined: Sun Mar 13, 2016 1:34 am
- Contact:
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1291 :
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.
-
- Posts: 6
- Joined: Sun Mar 13, 2016 1:34 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1291 :
Pooler extends Thread so call to super(r) will execute run(Runnable) of Thread.
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1291 :
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.
-
- Posts: 6
- Joined: Sun Mar 13, 2016 1:34 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1291 :
I got it now. Will h.start() call Pooler's run() method directly because h has been assigned a Pooler object?
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1291 :
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.
Who is online
Users browsing this forum: No registered users and 55 guests