标签:重写 接口 java 线程 throws 获取 代码 exception 唤醒 alt
//以下模拟3个窗口同时售卖5张车票的线程代码。 //可以说明runnable 接口优势中多线程共享一个公用资源 private int titickits =500000; public static void main(String[] args) throws InterruptedException { Titickits t=new Titickits(); Thread t1=new Thread(t,"窗口A"); Thread t2=new Thread(t,"窗口B"); Thread t3=new Thread(t,"窗口C"); t1.start(); t2.start(); t3.start(); t1.wait(); } public void run() { while(titickits>0) { titickits--; System.out.println(Thread.currentThread().getName()+"剩余"+titickits); } }
标签:重写 接口 java 线程 throws 获取 代码 exception 唤醒 alt
原文地址:https://www.cnblogs.com/lanSeGeDiao/p/9063269.html