比这篇新的文章:
Simple New Line Converter - CRLN DOS<=>UNIX,换行符替换工
比这篇旧的文章: Codee#993
作者: , 点击157次, 评论(0), 收藏者(0), , 打分:
所有评论,共0条:( 我也来说两句)
比这篇旧的文章: Codee#993
Codee#994 编辑代码
语言: C++, 标签: 无 2009/05/10发布 10个月前更新 | 编辑代码作者: , 点击157次, 评论(0), 收藏者(0), , 打分:
C++语言: Codee#994
01 #include "Thread.h"
02
03 Thread::Thread(){
04
05 }
06
07 Thread::~Thread(){
08
09 }
10
11 void* Thread::run0(void* opt)
12 {
13 Thread* p = (Thread*) opt;
14 p->run1();
15 return p;
16 }
17
18 void* Thread::run1()
19 {
20 _tid = pthread_self();
21 run();
22 _tid = 0;
23 pthread_exit(NULL);
24 }
25
26 bool Thread::start()
27 {
28 return pthread_create(&_tid, NULL, run0, this) == 0;
29 }
30
31 void Thread::join()
32 {
33 if( _tid > 0 ){
34 pthread_join(_tid, NULL);
35 }
36 }
02
03 Thread::Thread(){
04
05 }
06
07 Thread::~Thread(){
08
09 }
10
11 void* Thread::run0(void* opt)
12 {
13 Thread* p = (Thread*) opt;
14 p->run1();
15 return p;
16 }
17
18 void* Thread::run1()
19 {
20 _tid = pthread_self();
21 run();
22 _tid = 0;
23 pthread_exit(NULL);
24 }
25
26 bool Thread::start()
27 {
28 return pthread_create(&_tid, NULL, run0, this) == 0;
29 }
30
31 void Thread::join()
32 {
33 if( _tid > 0 ){
34 pthread_join(_tid, NULL);
35 }
36 }
所有评论,共0条:( 我也来说两句)
代码
