About Question enthuware.ocpjp.v7.2.1705 :

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
jklb
Posts: 17
Joined: Tue Dec 18, 2012 7:54 pm
Contact:

About Question enthuware.ocpjp.v7.2.1705 :

Post by jklb »

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?

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

Re: About Question enthuware.ocpjp.v7.2.1705 :

Post by admin »

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.

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

Re: About Question enthuware.ocpjp.v7.2.1705 :

Post by admin »

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.

jklb
Posts: 17
Joined: Tue Dec 18, 2012 7:54 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1705 :

Post by jklb »

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests