From c3bad6627daf0743daf33e201377f1e5d1fc40b7 Mon Sep 17 00:00:00 2001 From: pj3q7x5mz <1732875197@qq.com> Date: Mon, 21 Nov 2022 16:54:21 +0800 Subject: [PATCH] =?UTF-8?q?Delete=20'Java=E9=AB=98=E7=BA=A7=E7=89=B9?= =?UTF-8?q?=E6=80=A7=20-=20=E5=A4=9A=E7=BA=BF=E7=A8=8B=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=EF=BC=883=EF=BC=89=E7=BA=BF=E7=A8=8B=E5=90=8C=E6=AD=A5.txt'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... - 多线程基础(3)线程同步.txt | 36 ------------------- 1 file changed, 36 deletions(-) delete mode 100644 Java高级特性 - 多线程基础(3)线程同步.txt diff --git a/Java高级特性 - 多线程基础(3)线程同步.txt b/Java高级特性 - 多线程基础(3)线程同步.txt deleted file mode 100644 index 822cbad..0000000 --- a/Java高级特性 - 多线程基础(3)线程同步.txt +++ /dev/null @@ -1,36 +0,0 @@ -1.使用synchronized关键字同步线程 -package step2; - -public class Task { - - public static void main(String[] args) { - - final insertData insert = new insertData(); - - for (int i = 0; i < 3; i++) { - new Thread(new Runnable() { - public void run() { - insert.insert(Thread.currentThread()); - } - }).start(); - } - - } -} - -class insertData { - - public static int num = 0; - - /********* Begin *********/ - public synchronized void insert(Thread thread) { - - for (int i = 0; i <= 5; i++) { - num++; - System.out.println(num); - } - } - - /********* End *********/ -} -