package com.itheima;
//普通办理
class Sample implements Runnable{
public void run(){
try{
for(int i = 1; i <= 10; i++)
{
System.out.println(Thread.currentThread().getName());
Thread.sleep(1000);
}
}catch(InterruptedException e)
{
e.printStackTrace();
}
}
}
//vip办理
class Vip implements Runnable{
public void run(){
System.out.println("vip进行办理");
System.out.println(Thread.currentThread().getName());
}
}
public class Main{
public static void main(String[] args)throws Exception{
Thread sample = new Thread(new Sample(), "普通用户在办理服务");
Vip vip = new Vip();
Thread thread = new Thread(vip, "vip在办理服务");
sample.start();
for(int i = 1; i <= 10; i++)
{
Thread.sleep(1000);
if(i == 6)
{
thread.start();
thread.join();//进行插入
}
}
}
}
java基础案例8-2 Svip优先办理服务
最新推荐文章于 2023-02-27 09:58:22 发布