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.
The most simple way to protect a resource is to use a global thread lock.