About Question enthuware.ocpjp.v7.2.1705 :
Moderators: Site Manager, fjwalraven
-
- Posts: 17
- Joined: Tue Dec 18, 2012 7:54 pm
- Contact:
About Question enthuware.ocpjp.v7.2.1705 :
Won't the "t.join()" assure that any modifications made by thread t will be seen by the main thread? Won't that assure the value of sum will be 20?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1705 :
Yes, the join method provides "happen-before" semantics so all updates made by thread t will be seen by the main thread.
But that is not the issue here. The issue is that the update itself is faulty. When thread t tries to update 'sum', it does not acquire the same lock that is used by the main thread. So this update may step on the main thread's update.
HTH,
Paul.
But that is not the issue here. The issue is that the update itself is faulty. When thread t tries to update 'sum', it does not acquire the same lock that is used by the main thread. So this update may step on the main thread's update.
HTH,
Paul.
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1705 :
I see you are referring to the last part in the explanation. Yes, you are right. This should be fixed.
Thank you for your feedback.
-Paul.
Thank you for your feedback.
-Paul.
-
- Posts: 17
- Joined: Tue Dec 18, 2012 7:54 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1705 :
Actually, I was confused and your response helped clarify my understanding. But improving the explanation would help because I didn't get it the first time.
Thank you.
Thank you.
Who is online
Users browsing this forum: Google [Bot] and 1 guest