Commit 70d8a556 authored by e.maksimov2's avatar e.maksimov2
Browse files

Upload New File

parent 8a7ce4c6
#include <pthread.h>
#include "ADTQueue.h"
queue* q;
pthread_mutex_t m;
void* getData(void* args)
{
for (int i = 0; i < 5; i++)
{
push(q, (void*)i);
}
return NULL;
}
int main()
{
q = init(1000, sizeof(int));
pthread_t first, second;
int id1 = 1, id2 = 2;
pthread_mutex_init(&m, NULL);
q->m = m;
pthread_create(&first, NULL, getData, &id1);
pthread_create(&second, NULL, getData, &id2);
pthread_join(first, NULL);
pthread_join(second, NULL);
pthread_mutex_destroy(&m);
pop(q);
iterate(q);
clean(q);
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment