You need to implement the UpdateGrade() method

You are adding a public method named UpdateGrade to a public class named ReportCard. The code region
that updates the grade 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 UpdateGrade() method. What should you do?

You are adding a public method named UpdateGrade to a public class named ReportCard. The code region
that updates the grade 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 UpdateGrade() method. What should you do?

A.
Add private object named lockObject to the ReportCard class. place the code region inside the
following lock statement:
lock (lockObject)
{

}

B.
Place the code region inside the following lock statement:
lock (this)
{

}

C.
Add a public static object named lockObject to the ReportCard class. Place the code region inside the
following lock statement:
lock (typeof(ReportCard))
{

}

D.
Apply the following attribute to the UpdateGrade() method signature:
[MethodImpl(MethodImplOptions.Synchronized)]

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



Leave a Reply 0

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