最近用c语言写了个简单的队列服务,记录一下,文件结构为 main.c queue.c queue.h,代码如下:
主函数
#define NUM_THREADS 200
#include
#include
#include
#include
#include
#include
#include
struct threadArgs
{
struct queue *q;
char *c ;
};
void* putArg(void *params)
{
struct threadArgs *args = params;
putQueue(args->q, args->c);
}
int main()
{
pthread_t tids[NUM_THREADS]; //线程id
struct queue * g_q;
g_q = initQueue();
char c[LENTH] = "test\0";
char b[LENTH] = "btest\0";
char a[LENTH] = "atest\0";
char *h = "";
;
; i < NUM_THREADS; ++i ) {
struct threadArgs *args;
args = (struct threa