Esempio n. 1
0
static Consumer*
Consumer_start(Queue* queue, int id, F_GetItem* f_get_item)
{
	Consumer* consumer = Consumer_new(queue, id);

	consumer->f_get_item = f_get_item;
	pthread_create(consumer->thread, NULL, start_consumer, consumer);
	return consumer;
}
int main(void) {
    srand(time(NULL));
    stack_t stack = stack_new();
    hMutex = CreateMutex(
        NULL,
        FALSE,
        NULL);
    HANDLE * first_thread = Producer_new(stack);
    HANDLE * second_thread = Consumer_new(stack);
    while (!_kbhit());
    Producer_free(first_thread);
    Consumer_free(second_thread);
    CloseHandle(hMutex);
    _getch();
    system("cls");
    return 0;
}