1 Star 0 Fork 0

20145203 / the thirteenth week

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
createthread.c 685 Bytes
一键复制 编辑 原始数据 按行查看 历史
20145203 提交于 2016-12-22 10:41 . 新建 createthread.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
pthread_t ntid;
void printids( const char *s )
{
pid_t pid;
pthread_t tid;
pid = getpid();
tid = pthread_self();
printf("%s pid %u tid %u (0x%x) \n", s , ( unsigned int ) pid,
( unsigned int ) tid, (unsigned int ) tid);
}
void *thr_fn( void * arg )
{
printids( arg );
return NULL;
}
int main( void )
{
int err;
err = pthread_create( &ntid, NULL, thr_fn, "new thread: " );
if ( err != 0 ){
fprintf( stderr, "can't create thread: %s\n", strerror( err ) );
exit( 1 );
}
printids( "main threads: " );
sleep(1);
return 0;
}
C
1
https://gitee.com/gzsgzsgzs/the-thirteenth-week.git
git@gitee.com:gzsgzsgzs/the-thirteenth-week.git
gzsgzsgzs
the-thirteenth-week
the thirteenth week
master

搜索帮助