Posted on 2011-02-07 20:56
S.l.e!ep.¢% 阅读(327)
评论(0) 编辑 收藏 引用 所属分类:
Unix
pthread_mutex_t lock;
pthread_mutex_init(&lock, NULL);
clock_t start, end;
start = clock();
int ii = 0;
for( int i = 0; i <= 100000; i++ )
{
pthread_mutex_lock( &lock );
ii = i;
printf("%d \n", ii);
pthread_mutex_unlock( &lock );
}
end = clock();
printf("time: %f \n", (double)(end - start) / CLOCKS_PER_SEC );
pthread_mutex_destroy( &lock );
return 0;