请问继承方法实现线程,实例化的时候只new一个线程而不是三个,难道不也是只卖五张票?
public class Ticket extends Thread { private int tic = 5; @Override public void run() { while (tic > 0) { --tic; System.out.println(Thread.currentThread().getName() + "剩下" + tic + "张票"); } } public static void main(String[] args) { Ticket ticket = new Ticket(); Thread thread1 = new Thread(ticket, "线程1"); Thread thread2 = new Thread(ticket, "线程2"); Thread thread3 = new Thread(ticket, "线程3"); thread1.start(); thread2.start(); thread3.start(); } }