|
|
|
|
|
- Example: Communication between 2 threads
ThreadSendSignal (Example)
Example: Communication between 2 threads The following example is used communicate between two threads via ThreadWaitSignal and ThreadSendSignal. // -- Project initialization code GLOBAL gnAction is int  // Runs the thread1 ThreadExecute("Thread1", threadNormal, ProcThread1)  // Runs the thread2 ThreadExecute("Thread2", threadNormal, ProcThread2)  // Waits for the end of Thread1 before continuing the program execution ThreadWait("Thread1")
PROCEDURE ProcThread1() bContinue is boolean = True WHILE bContinue ThreadWaitSignal() SWITCH gnAction CASE 1: // <Process of action 1> CASE 2: // <Process of action 2> OTHER CASE: bContinue = False END ThreadSendSignal("Thread2") END Â // End of Thread2 ThreadStop("Thread2")
PROCEDURE ProcThread2() ... // <Code> ... gnAction = 1 ThreadSendSignal("Thread1") ThreadWaitSignal() ... // <Code> ... gnAction = 2 ThreadSendSignal("Thread1") ThreadWaitSignal() ... // <Code> ... gnAction = 3 ThreadSendSignal("Thread1") ThreadWaitSignal()
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|