FullSemaphore;//资源信号量:缓冲区满РHANDLE g_hEmptySemaphore;//资源信号量:缓冲区空РDWORD WINAPI Producer(LPVOID);//生产者线程РDWORD WINAPI Consumer(LPVOID);//消费者线程Рconst unsigned short PRODUCERS_COUNT=4;//生产者的个数Рconst unsigned short CONSUMERS_COUNT=3;//消费者的个数Рconst unsigned short THREADS_COUNT=PRODUCERS_COUNT+CONSUMERS_COUNT;//总线程数РHANDLE hThreads[PRODUCERS_COUNT];//各线程的handleРDWORD producerID[CONSUMERS_COUNT];//生产者线程的标识符РDWORD consumerID[THREADS_COUNT];//消费者线程的标识符Р/*----------------------------生产一个产品开始------------------------------*/Р//生产一个产品,输出其ID号Рvoid Produce()Р{Р?std::cout<<std::endl;Р?std::cerr<<"生产一个产品: "<<++ProductID;Р?std::cout<<std::endl;Р}Р/*----------------------------生产一个产品结束------------------------------*/Р/*----------------------把新生产的产品放入缓冲区开始------------------------*/Р//把新生产的产品放入缓冲区Рvoid Append()