Previous Section   Next Section

Q&A

Q1:

C# has a lock keyword. What is the equivalent keyword in C++?

A1:

There is no equivalent C++ keyword. However, the C# lock keyword behaves exactly the same as wrapping code with the Monitor::Enter and Monitor::Exit functions.

Q2:

Do I have to add synchronization as was done in this hour every time I access data?

A2:

Only if the data type you are trying to synchronize was created by you. The .NET Framework collection classes contain built-in synchronization for this purpose. Many of them contain their own lock and unlock functions.


  Previous Section   Next Section
Top