thread.c

来自「该源码是创维特ARM7 JX44B0X板的例子程序」· C语言 代码 · 共 41 行

C
41
字号
#include <stdio.h>#include <pthread.h>/* * thread application code, the multi-thread application start code of Linux application * compile : *          $arm-elf-gcc -Wl,-elf2flt -o thread thread.c -lpthread *          $cp thread /tftpboot/examples * run in target: *          #cd /var *          #ftp 192.168.1.180 *          ftp>bin *          ftp>cd /tftpboot/examples *          ftp>get thread *          ftp>by *          #./thread */void thread(void){    int i;    for(i=0;i<3;i++)    printf("This is a pthread.\n");}int main(int argc, char **argv){    pthread_t id;    int i,ret;    ret=pthread_create(&id,NULL,(void *) thread,NULL);    if(ret!=0){    printf ("Create pthread error!\n");    exit (1);    }    for(i=0;i<3;i++)    printf("This is the main process.\n");    pthread_join(id,NULL);    return (0);}

⌨️ 快捷键说明

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