From 20c30d26f8bab22a4cb6b6459962fa92d6da490f Mon Sep 17 00:00:00 2001 From: cy <1664593601@qq.com> Date: 星期一, 27 十一月 2023 14:20:29 +0800 Subject: [PATCH] feat: 漏洞修改 --- deploy-jar-single/src/main/java/com/consum/test/synchronizedCode.java | 94 +++++++++++++++++++++++----------------------- 1 files changed, 47 insertions(+), 47 deletions(-) diff --git a/deploy-jar-single/src/main/java/com/consum/test/synchronizedCode.java b/deploy-jar-single/src/main/java/com/consum/test/synchronizedCode.java index d27c5cd..d61d8e6 100644 --- a/deploy-jar-single/src/main/java/com/consum/test/synchronizedCode.java +++ b/deploy-jar-single/src/main/java/com/consum/test/synchronizedCode.java @@ -1,47 +1,47 @@ -package com.consum.test; - -/** - * 娴嬭瘯澶氱嚎绋嬪苟鍙� - */ -public class synchronizedCode implements Runnable { - - static synchronizedCode instance = new synchronizedCode(); - static int i = 0; - - static String key = "1"; - - public static void main(String[] args) throws InterruptedException { - for (int j=0;j<5;j++){ - Thread t1 = new Thread(instance); - t1.start(); - } - - System.out.println("绾跨▼鎵ц缁撴潫"); - } - - @Override - public void run() { - - String myKey; - if (key == "1"){ - myKey = "def"; - key = "2"; - } else { - myKey = "abc"; - key="1"; - } - - System.out.println(Thread.currentThread().getName() + ":" + myKey); - - synchronized (myKey){ - System.out.println(Thread.currentThread().getName() + "寮�濮嬭繍琛�"); - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.out.println("鎴戝彨"+ Thread.currentThread().getName()+"杩愯缁撴潫"); - } - } -} \ No newline at end of file +//package com.consum.test; +// +///** +// * 娴嬭瘯澶氱嚎绋嬪苟鍙� +// */ +//public class synchronizedCode implements Runnable { +// +// static synchronizedCode instance = new synchronizedCode(); +// static int i = 0; +// +// static String key = "1"; +// +// public static void main(String[] args) throws InterruptedException { +// for (int j=0;j<5;j++){ +// Thread t1 = new Thread(instance); +// t1.start(); +// } +// +// System.out.println("绾跨▼鎵ц缁撴潫"); +// } +// +// @Override +// public void run() { +// +// String myKey; +// if (key == "1"){ +// myKey = "def"; +// key = "2"; +// } else { +// myKey = "abc"; +// key="1"; +// } +// +// System.out.println(Thread.currentThread().getName() + ":" + myKey); +// +// synchronized (myKey){ +// System.out.println(Thread.currentThread().getName() + "寮�濮嬭繍琛�"); +// try { +// Thread.sleep(3000); +// } catch (InterruptedException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// System.out.println("鎴戝彨"+ Thread.currentThread().getName()+"杩愯缁撴潫"); +// } +// } +//} -- Gitblit v1.9.1