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.
About Question com.enthuware.ets.scjp.v6.2.429 :
Moderator: admin
-
- Posts: 19
- Joined: Mon Sep 01, 2014 9:45 pm
- Contact:
-
- Site Admin
- Posts: 10066
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.429 :
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.
If you like our products and services, please help us by posting your review here.
-
- Posts: 19
- Joined: Mon Sep 01, 2014 9:45 pm
- Contact:
-
- Posts: 57
- Joined: Sat Mar 01, 2014 1:48 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.429 :
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.admin wrote:Also, receiving an exception doesn't mean that the thread has stopped.
-
- Site Admin
- Posts: 10066
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.429 :
Not necessarily. You can put the call to start() within a try/catch block.
If you like our products and services, please help us by posting your review here.
-
- Posts: 57
- Joined: Sat Mar 01, 2014 1:48 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.429 :
Ah, I see thanks.admin wrote:Not necessarily. You can put the call to start() within a try/catch block.
Who is online
Users browsing this forum: No registered users and 164 guests