home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR4
/
V12N16.ZIP
/
SYNC.ZIP
/
SYNC4.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-26
|
981b
|
47 lines
/*---------------------------------------
SYNC4.C -- NT Synchronization Demo #4
(c) Charles Petzold, 1993
---------------------------------------*/
#include <windows.h>
#include <process.h>
#include <stdio.h>
HANDLE hEvent1, hEvent2 ;
int a [5] ;
void Thread (void * pParams)
{
int i, num = 0 ;
while (TRUE)
{
WaitForSingleObject (hEvent2, INFINITE) ;
for (i = 0 ; i < 5 ; i++)
a [i] = num ;
SetEvent (hEvent1) ;
num++ ;
}
}
int main (void)
{
hEvent1 = CreateEvent (NULL, FALSE, TRUE, NULL) ;
hEvent2 = CreateEvent (NULL, FALSE, FALSE, NULL) ;
_beginthread (Thread, 0, NULL) ;
while (TRUE)
{
WaitForSingleObject (hEvent1, INFINITE) ;
printf ("%d %d %d %d %d\n", a[0], a[1], a[2], a[3], a[4]) ;
SetEvent (hEvent2) ;
}
return 0 ;
}