|
发表于 2003-10-21 21:59:33
|
显示全部楼层
#include <pthread.h>
#include <stdio.h>
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
void unlock( void * arg )
{
pthread_mutex_unlock( &lock );
printf("unlock now\n");
}
void * function( void * arg )
{
while( 1 )
{
pthread_mutex_lock( &lock );
pthread_cleanup_push( &unlock, NULL );
/*
Any of the possible cancellation points could
go here.
*/
pthread_testcancel();
pthread_cleanup_pop( 1 );
}
}
main()
{
pthread_create(NULL,NULL,function,NULL);
}
测试正常
虽然后面有segment fault不过push还是起伤的
自己看看自己的代码吧 |
|