You need to implement the UpdateScore() method

You are adding a public method named UpdateScore to a public class named ScoreCard.
The code region that updates the score field must meet the following requirements:
It must be accessed by only one thread at a time.
It must not be vulnerable to a deadlock situation.
You need to implement the UpdateScore() method.
What should you do?

You are adding a public method named UpdateScore to a public class named ScoreCard.
The code region that updates the score field must meet the following requirements:
It must be accessed by only one thread at a time.
It must not be vulnerable to a deadlock situation.
You need to implement the UpdateScore() method.
What should you do?

A.
Option A

B.
Option B

C.
Option C

D.
Option D

Explanation:
http://blogs.msdn.com/b/bclteam/archive/2004/01/20/60719.aspx



Leave a Reply 5

Your email address will not be published. Required fields are marked *


Jun Yang

Jun Yang

why? I dont understand it…

playhard

playhard

lock (object){} = Monitor.Enter(object); try{}Finally{monitor.exit(object))

immune to a deadlock situation and locks the object

Lord Vader

Lord Vader

You create a dummy object and place a lock on it.
Insert the shared code in that lock statement. this way the shared code can only get updated by one thread at a time.
The lock(obj) syntax prevents deadlock by placing the exit of the lock in the finally clause