What is the lock keyword used for?

Junior C#

Answer

The lock keyword prevents multiple threads from accessing a shared resource at the same time.

It ensures thread safety.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice