没有合适的资源?快使用搜索试试~ 我知道了~
首页C++多线程基类C++多线程基类C++多线程基类
资源详情
资源评论
资源推荐

在原来的基础上,进行了加强,使之进一步接近 Java 中 Thread 和 Runnable 的用法。
下面是我写的基类,把代码保存在名为 Thread.h 的头文件中。
====================================传说中的分割线===============
==================
/*
* File: Thread.h
* Author: Null
* Blog: http://hi.baidu.com/hetaoos
* Created on 2008 年 7 月 30 日, 上午 10:13
*/
/*
* 在编译的时候记得加上参数:-lpthread
*
*/
#ifndef _THREAD_H
#define _THREAD_H
#include <pthread.h>
#include <unistd.h>
/*
* 线程运行实体类
*/
class Runnable
{
public:
//运行实体
virtual void run() = 0;
};
/*
* 线程类
*
*/
class Thread : public Runnable
{
private:
//线程初始化序号
static int threadInitNumber;
//当前线程初始化序号
int curThreadInitNumber;
//线程体
Runnable *target;
//当前线程的线程 ID
pthread_t tid;
//线程的状态
int threadStatus;
//线程属性
pthread_attr_t attr;



















安全验证
文档复制为VIP权益,开通VIP直接复制

评论3