1、Qt下新建一个控制台工程,因为多线程的库不是缺省的,pro工程中添加:
LIBS += -lpthread
2、下面写代码
#include <QCoreApplication>
#include<stdio.h>
#include <unistd.h>
#include<pthread.h>
int tickets=50;
pthread_mutex_t mutex_t=PTHREAD_MUTEX_INITIALIZER;
void *sell(void *station)
{
1、Qt下新建一个控制台工程,因为多线程的库不是缺省的,pro工程中添加:
LIBS += -lpthread
2、下面写代码
#include <QCoreApplication>
#include<stdio.h>
#include <unistd.h>
#include<pthread.h>
int tickets=50;
pthread_mutex_t mutex_t=PTHREAD_MUTEX_INITIALIZER;
void *sell(void *station)
{