1 继承Thread类,重写run方法.Thread类实现了Runnable接口. 2 实现Runnable接口,重写run方法.相比于继承Thread类,可以避免单继承的缺陷和实现资源共享. 举例:假设两个窗口在卖5张火车票. 继承Thread类方式: public class SharedDataThreadDemo { public static void main(String[] args) { TicketThread t1 = new TicketThread("1号窗口"…