When multiple GPL threads are employed within a single project, it is often necessary to synchronize them. For example, a server thread may wait for a client thread to post a command, and the client may wait for the server to respond.
Two or more threads can efficiently be synchronized by using the SendEvent and WaitEvent methods. Any GPL thread can send a synchronization message called an event to any other GPL thread. Up to 16 independent events per thread can be sent to permit the receiving thread to discriminate between types of events. The events are numbered 1 through 16. The target thread uses WaitEvent to efficiently wait for one or more of these events to be received. While a thread is waiting for an event, it uses almost no CPU time.