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){
		
	}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值