【请教】关于Linux中线程创建函数pthread_create的一个问题!!!
这样的一个简单程序:
///////////////////////////////////////////////////////////
#include <unistd.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
pthread_t touch_thread;
int handle_touch = 0;
void * touchThreadFunc( void * )
{
return 0;
}
int main(int argc, char* argv[])
{
for ( int i = 0; i < 10000; ++i )
{
handle_touch = pthread_create( &touch_thread, NULL, touchThreadFunc, NULL );
if ( handle_touch != 0 )
{
printf( "Error\n" );
exit( EXIT_FAILURE );
}
usleep( 10*1000 );
}
return 0;
}
//////////////////////////////////////////////////////////////////////
这个循环执行了256次后,pthread_create就失败了,请问这是为什么啊? 应该怎么解决呢?