What to use instead of the “lock” statement when the code is running on multiple machines?

后端 未结 5 2122
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-13 10:02

The lock statement ensures that one thread does not enter a critical section of code while another thread is in the critical section. However, it won\'t work if the workload is

5条回答
  •  难免孤独
    2021-02-13 10:54

    If you have access to a centralized SQL Server instance, you can use it to act as a distributed lock coordinator and manage the application locks using the sp_getapplock and sp_releaseapplock stored procedures.

    Application Locks (or Mutexes) in SQL Server 2005

提交回复
热议问题