閱讀107 返回首頁    go 技術社區[雲棲]


線程同步之MUTEX

You can use a mutex object to protect a shared resource from simultaneous access by multiple threads or processes. Each thread must wait for ownership of the mutex before it can execute the code that accesses the shared resource. For example, if several threads share access to a database, the threads can use a mutex object to permit only one thread at a time to write to the database.

The following example (comes from MSDN)uses the CreateMutex function to create a mutex object and the CreateThread function to create worker threads.

最後更新:2017-04-03 05:39:53

  上一篇:go java對象和json數據轉換實現方式2-使用gson實現
  下一篇:go Android Lint的使用