标签:com rup cat err 能力 子类 img 操作 getname
package DemoThread; //多个线程同时操作同一个对象 //买火车票的例子 public class TestThread02 implements Runnable{ //票数 private int ticketNums=10; @Override public void run() { while (true) { if(ticketNums<=0){ break; } try { Thread.sleep(200); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println(Thread.currentThread().getName() + "-->拿到了第" + ticketNums-- + "票"); } } public static void main(String[] args) { TestThread02 testThread02=new TestThread02(); new Thread(testThread02,"阿优").start(); new Thread(testThread02,"大黄").start(); new Thread(testThread02,"小柔").start(); } }
标签:com rup cat err 能力 子类 img 操作 getname
原文地址:https://www.cnblogs.com/IanIan/p/13769848.html