public class Test { public static void main(String[] args) { List<String> list = new ArrayList<>(1); LockEntity lockEntity = new LockEntity(); new Thread(new PThread(list, lockEntity)).start(); new Thread(new CThread(list, lockEntity)).start()
public class Test { public static void main(String[] args){ //创建一个阻塞队列,边界为1 BlockingQueue<String> queue = new ArrayBlockingQueue<String>(1); new Thread(new PThread(queue)).start(); new Thread(new CThread(queue)).start(); }} /** * 生产者 */class P
public class Test { public static void main(String[] args) throws InterruptedException { List<String> queue = new ArrayList<>(); new Thread(new PThread(queue)).start(); new Thread(new CThread(queue)).start(); }} /** * 生产者 */class PThread imple