JavaSE多线程nomal

package com.thread.normal;

/** 
 * @ClassName: 
 * @author: YDJ
 * @Date: 2019年11月4日 下午10:09:42
 * @description: 
 */

public class NormalThreadTest {
	
	public static void main(String[] args) throws Exception {
		long start = System.currentTimeMillis();
		//开启够买厨具线程
		ShoppingThread shopping = new ShoppingThread();
		shopping.start();
		shopping.join();//保障厨具购买并送货
		//获取到购买厨具
		KitchenWare kc = shopping.kc;
		
		//买食材
		FoodMateral fm = new FoodMateral();
		Thread.sleep(2000);
		System.out.println("第二步: 食材已经到位");
		// 烹饪美食
		cooking(kc, fm);
		System.out.println("第三步:美食烹饪完成");
		long end = System.currentTimeMillis();
		System.out.println("烹饪美食时间为》"+(end-start));
		
	}
	
	
	static class ShoppingThread extends Thread{
		
		//厨具对象引用
		private KitchenWare kc;
		
		@Override
		public void run() {
			System.out.println("第一步:网上下单");
			System.out.println("第一步:等待厨具");
			try {
				Thread.sleep(5000);//等待厨具时间
			} catch (InterruptedException e) {
				
				e.printStackTrace();
			}
			System.out.println("第一步:快递到货");
			//生产厨具
			kc = new KitchenWare();
		}
	}
	
	
	
	/**
	 * 厨具类
	 * @author YDJ
	 *
	 */
	static class KitchenWare {
		
		
	}
	/**
	 * 食材类
	 * @author YDJ
	 *
	 */
	
	static class FoodMateral{
		
	}
	/**
	 * 定义烹饪食物的方法
	 * @param kc
	 * @param fm
	 */
	static void cooking(KitchenWare kc,FoodMateral fm){
		
	}

}

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页