linux 线程里面创建线程吗 Linux线程里面分主线程和从线程吗?具体有什么区别。求大神
linux\u4e2dmain()\u4e3b\u7a0b\u5e8f\u91cc\u521b\u5efa\u4e00\u4e2a\u65b0\u7ebf\u7a0b\u540e\uff0c\u8fd8\u80fd\u518d\u5efa\u4e2a\u7ebf\u7a0b\u5417\uff1fmain()\u4e3b\u7a0b\u5e8f\u91cc\u521b\u5efa\u4e00\u4e2a\u65b0\u7ebf\u7a0b\uff1a
(void*) thread2;
pthread_t id2;
main(){
ret=pthread_create(&id,NULL,(void*) thread,NULL);
if (ret!=0)
{
printf("Create pthread error!\n");
exit (1);
}
//\u7b2c\u4e8c\u4e2a\u7ebf\u7a0b
ret=pthread_create(&id2,NULL,(void*) thread2,NULL);
if (ret!=0)
{
printf("Create pthread2 error!\n");
exit (1);
}
}
\u4f60\u6700\u591a\u53ef\u4ee5\u521b\u5efa1024\u4e2a\u7ebf\u7a0b
\u9996\u5148\u6709\u4e00\u70b9\u8981\u6e05\u695a\uff0cLinux\u7a0b\u5e8f\u542f\u52a8\u9ed8\u8ba4\u6709\u4e00\u4e2a\u4e3b\u8fdb\u7a0b(\u6709\u4eba\u53eb\u5b83\u4e3b\u7ebf\u7a0b)\uff0c\u5165\u53e3\u662fmain()\uff0c\u5f53\u4f60\u521b\u5efa\u4e00\u4e2a\u7ebf\u7a0b\u540e\uff0c\u8fd9\u4e2a\u7ebf\u7a0b\u53ea\u5728\u7ebf\u7a0b\u5165\u53e3\u51fd\u6570\u91cc\u9762\u8fd0\u884c\uff0c\u8ddf\u4e3b\u8fdb\u7a0b\u6ca1\u6709\u5173\u7cfb\u4e86\uff0c\u4e3b\u8fdb\u7a0b\u53ef\u4ee5\u7ee7\u7eed\u8fd0\u884c\u63a5\u7528\u6237\u6307\u4ee4\u3002
\u6ca1\u6709\u4e3b\u7ebf\u7a0b\u548c\u4ece\u7ebf\u7a0b\u7684\u8bf4\u6cd5\u54e6\uff0c\u770b\u4f60\u8981\u505a\u4ec0\u4e48\u4e86\u3002
扩展阅读:linux杀死进程命令kill 9 ... cpu天梯图 ... linux系统创建两个线程 ... linux轻型线程如何创建 ... windows创建线程函数 ... c 创建线程 ... linux创建100个线程 ... linux线程分离 ... linux创建线程的三种方法 ...