About Question enthuware.ocpjp.v21.2.4000 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
shear12345
Posts: 18
Joined: Wed Feb 12, 2025 4:56 pm

About Question enthuware.ocpjp.v21.2.4000 :

Post by shear12345 »

One of the correct answers suggests that the call to "Thread.sleep(10000)" can be replaced with "while(!isInterrupted()) {}". However, the context in which suggested replacement is within a class that implements the Runnable interface. The A class does NOT extend the Thread class. So there is no "isInterrupted" method to be called in this context. The aforementioned correct answer should have it's wording changed to suggest "while(!Thread.interrupted()) {}". This caused me to avoid this answer, because I knew that the Runnable functional interface does not define a default method called "isInterrupted"; and thus one of my answers was marked as incorrect.

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

Re: About Question enthuware.ocpjp.v21.2.4000 :

Post by admin »

You are right. Besides that there is another issue with the question. The main thread creates a virtual thread and since virtual threads are always daemon threads, the JVM will exit without waiting for the thread t to finish.
Both are now fixed and the explanation has been enhanced to explain both the points.

thank you for your feedback!

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests