As the sentence threadcounter++; is not atomic and synchronization in run() is not effective (because each thread will get a lock of a different TestClass object) wouldn't be a more correct answer something like this?:
Total of 5 numbers will be printed (some may be repeated or missed) with "N Done" anywhere in the sequence where N cannot be determined.
About Question com.enthuware.ets.scjp.v6.2.484 :
Moderator: admin
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.484 :
The given answer is "Numbers 1 to 5 will be printed (some may be repeated or missed) with "N Done" anywhere in the sequence where N cannot be determined." and it is correct because the code can never print any number other than 1 to 5.
"Total of 5 numbers ... " is not one of the options. Had it been an option, it would have been correct as well.
"Total of 5 numbers ... " is not one of the options. Had it been an option, it would have been correct as well.
Who is online
Users browsing this forum: Google [Bot] and 33 guests