package com.tedu.threadStudy;
public class studyTicket {
public static void main(String[] args) {
YouThread youThread = new YouThread();
Thread thread = new Thread(youThread,"窗口1");
Thread thread2 = new Thread(youThread,"窗口2");
Thread thread3 = new Thread(youThread,"窗口3");
thread.start();
thread2.start();
thread3.start();
}
}
class YouThread implements Runnable{
int ticket = 100;
@Override
public void run() {
while (ticket>0){
System.out.println("正在售卖第"+(ticket--)+"张票");
}
// while (true){
// if (ticket>0){
// System.out.println(Thread.currentThread().getName()+"...卖出第"+(ticket--)+"张票");
// }else {
// break;
// }
// }
}
}