Page 1 of 1
About Question enthuware.ocpjp.v7.2.1391 :
Posted: Sat Feb 08, 2014 2:30 am
by icepeanuts
I am just curious to know if class JerkyThread correctly overrides run() method because its implementation uses synchronized keyword. However, class Thread's run() does not have it.
Re: About Question enthuware.ocpjp.v7.2.1391 :
Posted: Sat Feb 08, 2014 2:32 am
by admin
Yes, it is alright for a subclass to add synchronized keyword to an overridden method.
HTH,
Paul.
Re: About Question enthuware.ocpjp.v7.2.1391 :
Posted: Sat Feb 08, 2014 2:47 am
by icepeanuts
thanks
Re: About Question enthuware.ocpjp.v7.2.1391 :
Posted: Tue Jun 23, 2015 6:54 am
by Alexey Berezkin
Is it OK that we don't take into considerations possible things with per-thread variables caching? I mean, when we have 2 threads which a) access some variable without synchronization and b) this variable is not marked volatile — then the update issued by one thread may be not seen by the second one. This behaviour is not taken into consideration thoughout all the tests. (If taken, in this question answer 0 2 2 is also possible). Is it intentional omission that also exists on the real exam?
Re: About Question enthuware.ocpjp.v7.2.1391 :
Posted: Tue Jun 23, 2015 11:43 am
by admin
We haven't see candidates getting question on volatile but you are right. The question should take into account this possibility. Either the variable should be made volatile or the getData method should be made synchronized.
We will check other questions as well to make sure this point is covered.
thank you for your feedback!