java???????????????????
???????????? ???????[ 2017/3/15 10:16:59 ] ??????????????????? Java
	????0??????
	??????????????????????????????????????????????????????????????????????????????????????????????????????????
	????1?????API????
	????public final void notify()
	??????????????????????????????????????????????????????????????????????????????
	????public final void wait()
	???????????????д?????????????????????????????????????????????????????????? notify ???????? notifyAll ?????????????????????????????????????????????????????????????????????????С?
	????“????????????????????????????JVM??????????????????????????????????????????????????????”??
	????wait()??notify()??notifyAll()????Щ?????????????????????У?????????м????????????в???????????????????У????????????????????????????????????????????????????????????????????????????????????????????????????????????????object???С?
	????2 ?????????
	?????????
	????//???????????this??
	????public class Storage<T> {
	????// ????洢??
	????private final int MAX_SIZE = 1000;
	????private int storageSize = 100;
	????private Object[] data;
	????private int top = 0;
	????public Storage(int size) {
	????size = size <= 0 ? storageSize : size;
	????size = size > this.MAX_SIZE ? this.MAX_SIZE : size;
	????this.storageSize = size;
	????data = new Object[this.storageSize];
	????}
	????public int getStorageSize() {
	????return storageSize;
	????}
	????public synchronized T pop() {
	????while (top == 0) {
	????try {
	????//???
	????wait();
	????} catch (Exception ex) {
	????ex.printStackTrace();
	????}
	????}
	????top--;
	????T t = (T) data[top];
	????//???????????
	????notifyAll();
	????return t;
	????}
	????public synchronized void push(T t) {
	????while (top == storageSize) {
	????try {
	????wait();
	????} catch (Exception ex) {
	????ex.printStackTrace();
	????}
	????}
	????data[top++] = t;
	????notifyAll();
	????}
	????}
	??????????
	????public class Producer implements Runnable {
	????private Storage<String> storage;
	????private volatile boolean breakLoop = false;
	????public Producer(Storage<String> storage) {
	????this.storage = storage;
	????}
	????@Override
	????public void run() {
	????int index = 1;
	????while (true) {
	????if (breakLoop) {
	????break;
	????}
	????try {
	????Thread.sleep(1000);
	????} catch (Exception ex) {
	????ex.printStackTrace();
	????}
	????storage.push("data:" + index);
	????System.out.println("Producer data:" + index);
	????index++;
	????}
	????}
	????public void destroy() {
	????this.breakLoop = true;
	????}
	????}
	??????????
	????public class Consumer implements Runnable {
	????private Storage<String> storage;
	????private volatile boolean breakLoop = false;
	????public Consumer(Storage<String> storage) {
	????this.storage = storage;
	????}
	????@Override
	????public void run() {
	????while (true) {
	????if (breakLoop) {
	????break;
	????}
	????try {
	????Thread.sleep(1000);
	????} catch (Exception ex) {
	????ex.printStackTrace();
	????}
	????System.out.println(Thread.currentThread().getName() + "Consumer:" + storage.pop());
	????}
	????}
	????public void destroy() {
	????this.breakLoop = true;
	????}
	????}
	
??????
					
					???·???
App??С????H5?????????????????Щ??
2024/9/11 15:34:34?????????????????????????
2024/9/10 11:13:49P-One ???????????????????????????????????????
2024/9/10 10:14:12???????????????????????????
2024/9/9 18:04:26??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44
					
			
								
								
								
								
								
								
								
								
								
								
				
sales@spasvo.com