C# Lock Statement

lock-statements
In this chapter you will learn:

  • What is Lock Statement in C#?
  • What is the benefit of using lock statement in C#?
  • How to use it in C# programming?

The lock statement handle lock segment as a critical section and lock the object during the execution of program from other thread. Once the execution is completed it releases the lock and frees objects.

Example:

Output

My name is Steven Clark
__

Summary

In this chapter, you learned what Lock statement is in C# and how to use it in C# programming. In next chapter you will learn about Using Statement in C#.



Leave a Reply

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