int main()
{
struct rb_tree *tree;
int i, rc;
unsigned int t;
pthread_t a[2];
srand(time(NULL));
t = clock();
for (i = 0; i < 2; ++i)
{
rc = pthread_create(&a[i], NULL, do_operation, tree);
printf("%d\n", rc);
}
for (i = 0; i < 2; ++i)
{
pthread_join(a[i], NULL);
}
t = clock() - t;
printf("time: %d sec.\n", t);
Print(tree, 0);
return 0;
}
void *do_operation(void *arg)
{
struct rb_tree *tree = arg;
int i = 0;
while (i != 100)
{
tree = Insert(tree, rand()%100);
i++;
}
pthread_exit(NULL);
}