设计一个多线程程序如下:设计一个火车售票模拟程序.假如火车站要有100张火车票要卖出,现在有5个售票点同时售票,用5个线程模拟这5个售票点的售票情况 1.要求打印出每个售票点所卖出的票号 2.各售票点不能售出相同票号的火车票 package com.hebust.java.third; import java.util.Random; public class SaleTicket implements Runnable { public int total; public int count;…
数据类: package Thread.MyCommon; public class Data { public int num = 0; public synchronized int getEven() { ++num; Thread.yield();//让另外线程先执行,加大测试效果几率 ++num; return num; } } 线程类: package Thread.MyCommon; public class myThread implements Runnable { priva…
1.创建Queue.java public class Queue { private LinkedList<Object> list = new LinkedList<Object>() ; private final int minSize = 0 ; ; private final int maxSize ; private AtomicInteger count = new AtomicInteger(0) ; public Queue(int size){ this.ma…