GIAC
GSSP-NET · Question #286
GSSP-NET Question #286: Real Exam Question with Answer & Explanation
The correct answer is C. Call the Monitor.Enter method before the block of code that needs to be synchronized. F. Call the Monitor.Exit method after the block of code that needs to be synchronized.. See the full explanation below for the reasoning.
Question
You work as a Windows Application Developer for ABC Inc. The company uses Visual Studio .NET 2008 as its application development platform. You create a Windows Forms application using .NET Framework 3.5. You create multiple threads in the application and the threads will execute the same method. You want to synchronize access to a block of code within the method; thus, no two threads execute the block at the same time. What will you do to accomplish this? Each correct answer represents a part of the solution. Choose two.
Options
- AAdd a SynchronizationAttribute attribute to the method that the multiple threads will call.
- BCall the Interlocked.Increment method before the block of code that needs to be synchronized.
- CCall the Monitor.Enter method before the block of code that needs to be synchronized.
- DCall the Interlocked.Decrement method after the block of code that needs to be synchronized.
- EAdd a Semaphore object to the method that the multiple threads will call.
- FCall the Monitor.Exit method after the block of code that needs to be synchronized.
Community Discussion
No community discussion yet for this question.