Thread Synchronization Manual

Table of Contents

About

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.

Note
Locks should be used to avoid crashes when seldom used resources are accessed and to protect single threaded operations.
Warning
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.

Warning
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.

Further Reading