package ProduceConsumeProblems; public class ProducerAndConsumer { private int head=0;//队头 private int tail=1;//队尾 public final int Num=6;//缓冲区大小 public char data[]=new char[Num]; public synchronized void inqueue(char c){ while((tail+1)%Num==head){
用pthread 实现 生产消费模型 /* * File : pc.c * * Title : Demo Producer/Consumer. * * Short : A solution to the producer consumer problem using * pthreads. * * Long : * * Author : Andrae Muys * * Date : 18 September 1997 * * Revised : */