thread.c

来自「ok2440开发板带的linux下的应用程序实验」· C语言 代码 · 共 27 行

C
27
字号
#include<stdio.h>
#include<stddef.h>
#include<unistd.h>
#include<pthread.h>
thread1()
{
	printf("Iam the thread\n");
	sleep(1);
}
main()
{
	int ret;
	pthread_t id;
	ret=pthread_create(&id,NULL,(void*)thread1,NULL);
        if(ret!=0)
        {	
			printf("thread_send error\n");
			exit(1);
		}
        while(1)
        {
        printf("I am the main-thread\n");
        sleep(1);
        }
}

⌨️ 快捷键说明

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