Chinaunix首页 | 论坛 | 博客
  • 博客访问: 969084
  • 博文数量: 200
  • 博客积分: 5011
  • 博客等级: 大校
  • 技术积分: 2479
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-27 15:07
文章分类

全部博文(200)

文章存档

2009年(12)

2008年(190)

我的朋友

分类:

2008-12-09 18:57:51

11.3 thread identification

每个thread都自己的thread id, 类型用pthread_t表示,今对于一个进程有意义。

#include

 

int pthread_equal(pthread_t tid1, pthread_t tid2);

 

Returns: nonzero if equal, 0 otherwise

对比两个thread id是否相同。

 

#include

 

pthread_t pthread_self(void);

 

Returns: the thread ID of the calling thread

查看当前threadid.

使用这两个函数,可以让master thread将一个队列的任务分别标上不同的thread id标记,然后各个thread都屈从队列里找与自己id相同的任务,然后去处理。这就是分配任务。

阅读(694) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~