最近在复习操作系统,随手写两种Java实现生产者消费者模型的方式 一、信号量 import java.util.Queue; import java.util.Random; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.Semaphore; class MessageQueue { private static final Semaphore FULL = new Semaphore(0); private static final Semaphore EMPTY