執行緒池的乙個例子

2021-06-10 07:28:09 字數 1504 閱讀 8499

執行緒池的乙個例子

threadpool.h:

// threadpool.h: inte***ce for the cthreadpool class.

////

#if !defined(afx_threadpool_h__e4160016_0fd0_4e25_a708_a3240945c9b9__included_)

#define afx_threadpool_h__e4160016_0fd0_4e25_a708_a3240945c9b9__included_

#if _msc_ver > 1000

#pragma once

#endif // _msc_ver > 1000

#include #define max_thread 1000 //最大的執行緒數 。。

typedef void (callback *_proccallback)(lpvoid );

class cthreadpool

;#endif // !defined(afx_threadpool_h__e4160016_0fd0_4e25_a708_a3240945c9b9__included_)

threadpool.c

// threadpool.cpp: implementation of the cthreadpool class.

////

#include "threadpool.h"

#include //

// construction/destruction

//cthreadpool::cthreadpool()

cthreadpool::~cthreadpool()

int cthreadpool::threadpoolinit(uint threadnum)

} ispoolstart = true;

return dwthread;

}dword winapi cthreadpool::threadproc(lpvoid lparam)

break;

case wait_object_0:

break;

default: //出錯了。。。

return 0;

} }return 0;

}int cthreadpool::postjob(_proccallback _proc,lpvoid lparam)

waitforsingleobject(jobevent,infinite);

jobproc = _proc;

joblparam = lparam;

setevent(hevent); //有任務了。。

return workingthread;

}int cthreadpool::stopthreadpool()

LineDDA的乙個例子

unit unit1 inte ce uses windows,messages,sysutils,variants,classes,graphics,controls,forms,dialogs,extctrls,stdctrls,buttons type tfmmain class tform ...

SQL GROUP CONCAT的乙個例子

我有乙個這樣的資料庫 user info 現在有乙個需求是把這樣 9 條記錄按照 username 來 group 成3條記錄 目標 shu female 201 lee male 202 yuki female 181 如果用select from user info group by usern...

explode的乙個例子

select level as level,explode split 1,2,3 as value 可以生成結果 level value level 1 level 2 level 3 lateral view 1.lateral view 用於和udtf函式 explode,split 結合來使...