package com.exception; public class TestThread3 implements Runnable { private int a = 10; @Override public void run() { while(true){ if (a<=0){ break; } System.out.println(Thread.currentThread().getName()+"拿到了第"+a--+"张票"); } } public static void main(String[] args) { TestThread3 t1 = new TestThread3(); new Thread(t1,"feifei").start(); new Thread(t1,"yy").start(); new Thread(t1,"weiwei").start(); } }
Runnable 一个卖票小案例
最新推荐文章于 2024-07-13 13:55:40 发布