come istanzio n thread di tipo produttore ed altrettanti di tipo consumatore ?

grazie


codice:
int array[100];

/* PRODUTTORE */

hMutex=CreateMutex(NULL, FALSE,NULL);
while(.....)
{
               WaitForSingleObject(hMutex,INFINITE);

               for(int i=0; i<100; i++)
               array[i]=rand();

               ReleaseMutex(hMutex);
              Sleep(50);

}


/* CONSUMATORE */

hMutex=CreateMutex(NULL, FALSE,NULL);
while(.....)
{
               WaitForSingleObject(hMutex,INFINITE);

               for(int i=0; i<100; i++)
               printf(%d\n,array[i]);

               ReleaseMutex(hMutex);
              Sleep(250);

}