⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 createthread.c

📁 此源码是著名的教材BeginningLinux Programming中文名字叫Linux程序设计书中的源代码
💻 C
字号:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>

int * thread(void * arg)
{
	pthread_t newthid;

	newthid = pthread_self();
	printf("this is a new thread, thread ID = %d\n", newthid);
	return NULL;
}

int main(void)
{
	pthread_t thid;

	printf("main thread ,ID is %d\n",pthread_self());
	if(pthread_create(&thid, NULL, (void *)thread, NULL) != 0) {
		printf("thread creation failed\n");
		exit(1);
	}
	exit(0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -