About Question enthuware.ocpjp.v7.2.1391 :
Moderators: Site Manager, fjwalraven
-
- Posts: 53
- Joined: Thu Nov 22, 2012 12:01 am
- Contact:
About Question enthuware.ocpjp.v7.2.1391 :
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.
-
- Site Admin
- Posts: 10389
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1391 :
Yes, it is alright for a subclass to add synchronized keyword to an overridden method.
HTH,
Paul.
HTH,
Paul.
-
- Posts: 53
- Joined: Thu Nov 22, 2012 12:01 am
- Contact:
-
- Posts: 20
- Joined: Fri Jun 19, 2015 9:17 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1391 :
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?
-
- Site Admin
- Posts: 10389
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1391 :
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!
We will check other questions as well to make sure this point is covered.
thank you for your feedback!
Who is online
Users browsing this forum: No registered users and 16 guests