这里的多是指多种类型
原理
同步关系:父亲和女儿 母亲和儿子
互斥关系:父亲和母亲
儿子和女儿间没有同步互斥关系
代码实现
#include<pthread.h>
#include<semaphore.h>
#include<iostream>
#include<unistd.h>
#include<time.h>
sem_t plate, apple, orange;
void* father(void* no)
{
while (true)
{
sem_wait(&plate);
//不要使用using namespace std
std::cout << "father input a apple" << std::endl;
sem_post(&apple);
sle