This is simply saying that an InterruptedException will be thrown when a thread, say Thread A, is ALREADY on either wait, join or sleep while an interrupt is being called on THE SAME THREAD, i.e. Thread A.calling interrupt() will cause an InterruptedException ONLY if the thread on which interrupt() is called, is blocked on an invocation of the wait, join, or sleep, methods of this class.
About Question enthuware.ocpjp.v8.2.1324 :
Moderator: admin
-
- Posts: 106
- Joined: Mon Mar 28, 2016 11:36 pm
- Contact:
About Question enthuware.ocpjp.v8.2.1324 :
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1324 :
That is correct.
If you like our products and services, please help us by posting your review here.
-
- Posts: 106
- Joined: Mon Mar 28, 2016 11:36 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1324 :
Thanks. Have a good weekend.admin wrote:That is correct.
-
- Posts: 125
- Joined: Thu Jul 05, 2018 6:44 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1324 :
Hi
then the situation would not be so clear.
Cheers.
This, luckily, is not true, and hence is not marked as a correct answer. But this is not true either:It will run and will ALWAYS end with an InterruptedException stack trace on the command line.
The key thing is the wordsThis is very likely to happen but not with 100% surety. In the exam, watch for statements like this on thread based questions.
The program doesn't end with an IE stack trace. It's caught. That's the whole point of the exception handler. I understand you might think I'm being pedantic, but I think the language here (everywhere) is important. IE is a subclass of E, IE is thrown, IE is caught, and the program terminates cleanly. If there were not the lineend with an InterruptedException stack trace
Code: Select all
System.out.println("Ending loop");
Cheers.
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1324 :
There is a call to e.printStackTrace(); in the catch block, so it could potentially print the stack trace on the command line if there is an exception.
A stack trace can be printed by the program code as well! The problem does not end because of the exception but may end with this output on the command line.
A stack trace can be printed by the program code as well! The problem does not end because of the exception but may end with this output on the command line.
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 81 guests