Page 1 of 1
About Question com.enthuware.ets.scjp.v6.2.429 :
Posted: Sat Sep 13, 2014 9:25 am
by tanzwud
Which of the following calls will not stop a thread from executing ?
Assume that the thread is already started.
Why correct answer is
start()
It will throw an exception as the thread is already started.
As soon as we have exception, the thread will not execute any longer and it will stop a thread? Or I'm missing something.
Re: About Question com.enthuware.ets.scjp.v6.2.429 :
Posted: Sat Sep 13, 2014 8:47 pm
by admin
That is not true. The caller thread will receive the exception. Not the thread on which you have called start. That will keep on running normally. Also, receiving an exception doesn't mean that the thread has stopped.
Re: About Question com.enthuware.ets.scjp.v6.2.429 :
Posted: Thu Sep 18, 2014 6:17 am
by tanzwud
Many THX
Re: About Question com.enthuware.ets.scjp.v6.2.429 :
Posted: Mon Mar 26, 2018 1:47 pm
by TwistedLizard
admin wrote:Also, receiving an exception doesn't mean that the thread has stopped.
But a thread that calls start() on itself, and must obviously have already been started in order to do so, will terminate? I believe I can demonstrate that.
Re: About Question com.enthuware.ets.scjp.v6.2.429 :
Posted: Mon Mar 26, 2018 8:59 pm
by admin
Not necessarily. You can put the call to start() within a try/catch block.
Re: About Question com.enthuware.ets.scjp.v6.2.429 :
Posted: Tue Mar 27, 2018 1:24 am
by TwistedLizard
admin wrote:Not necessarily. You can put the call to start() within a try/catch block.
Ah, I see thanks.