Thread Synchronization Manual

内容表

关于

In a multi-thread environment it can happen that different threads try to access the same resource at the same time. When this happens the handled resource can become corrupted which can lead to crashes. Therefore one must protect such resources with different tools so that only one thread at a time can access it. Typically a semaphore stores a "locked" state. If a thread tries to access the semaphore it will either set the state to "locked" or it will wait until the semaphore is unlocked.

注意
Locks should be used to avoid crashes when seldom used resources are accessed and to protect single threaded operations.
警告
Make sure that a thread releases a lock after it has finished or a deadlock will be the result.
For MAXON API thread locks see Locks & Synchronization Manual and also Condition Variables Manual .

Thread Lock

The most simple way to protect a resource is to use a global thread lock.

警告
As this blocks all threads it should only be used if really necessary, a local semaphore is a more elegant and efficient solution to parallel thread data access.

延伸阅读