摘要:
1) 在高内聚低耦合的前提下,线程操作资源类 资源类 class Ticket{ private int num = 30; public void sale(){ System.out.println("sale"); } } 主进程 public static void main(String[ 阅读全文
posted @ 2021-02-26 23:57
樱花葬礼
阅读(42)
评论(0)
推荐(0)
摘要:
方式1: 继承Thread创建多线程 class MyThread extends Thread{ public MyThread(){ } public MyThread(String name){ super(name); } @Override public void run() { Syst 阅读全文
posted @ 2021-02-26 22:45
樱花葬礼
阅读(57)
评论(0)
推荐(0)
摘要:
资源类: class Phone{ public synchronized void sendEmail() throws Exception{ System.out.println(" Email"); } public synchronized void sendSMS() throws Exc 阅读全文
posted @ 2021-02-26 21:53
樱花葬礼
阅读(35)
评论(0)
推荐(0)