Skip to content

Commit bc9a7bf

Browse files
author
chenzhuo
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # src/main/java/com/concurrent/volatilelearn/VolatileOne.java
1 parent 9229263 commit bc9a7bf

7 files changed

Lines changed: 92 additions & 12 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.concurrent.cyclicbarrierlearn.map;
2+
3+
import java.util.HashMap;
4+
import java.util.concurrent.ExecutorService;
5+
import java.util.concurrent.Executors;
6+
7+
/**
8+
* @author by chenzhuo
9+
* @Description
10+
* @Date 2019/7/3 13:45
11+
**/
12+
public class HashMapTest {
13+
14+
public static HashMap hashMap = new HashMap(2);
15+
16+
public static void main(String[] args) throws InterruptedException {
17+
Thread t1 = new Thread(() -> {
18+
for (int i = 1; i <= 100000; i++) {
19+
int result = i;
20+
new Thread(() -> hashMap.put(result, result), "cc" + i).start();
21+
}
22+
23+
});
24+
t1.start();
25+
Thread.sleep(5000);
26+
System.err.println("11");
27+
for (int i = 1; i <= 100000; i++) {
28+
Integer value = (Integer) hashMap.get(i);
29+
if (value == null) {
30+
System.out.println(i + "数据丢失");
31+
}
32+
}
33+
}
34+
}
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
package com.jvm.classloader.relyclass;
22

3+
import java.lang.reflect.Field;
4+
import java.sql.DriverManager;
5+
36
/**
47
* @ClassName Test1
58
* @Author chenzhuo
69
* @Version 1.0
710
* @Date 2019-06-25 22:06
811
**/
912
public class Test1 {
13+
1014
static {
1115
System.out.println(Test1.class.getClassLoader());
1216
}
1317

14-
public static void main(String[] args) {
15-
System.out.println(System.getProperty("sun.boot.class.path"));
16-
System.out.println(System.getProperty("java.ext.dirs"));
17-
System.out.println(System.getProperty("java.class.path"));
18+
public static void main(String[] args) throws Exception {
19+
1820
}
1921
}

src/main/java/com/jvm/classloader/relyclass/TestOne.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class TestOne {
1818
}
1919

2020
public static void main(String[] args) {
21-
System.out.println("sss");
21+
2222
}
2323
}
2424

src/main/java/com/share/classloader/BootstrapClassloader1.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
**/
1111
public class BootstrapClassloader1 {
1212
public static void main(String[] args) {
13-
URL[] urls = sun.misc.Launcher.getBootstrapClassPath().getURLs();
13+
URL[] urls =
14+
sun.misc.Launcher.getBootstrapClassPath()
15+
.getURLs();
1416
for (URL url : urls) {
1517
System.out.println(url.toExternalForm());
1618
}

src/main/java/com/share/classloader/ModuleManager.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@
1818
* @Date 2019-06-30 14:22
1919
**/
2020
public class ModuleManager {
21-
private ExecutorService executor = Executors.newFixedThreadPool(8);
22-
private Map<String, Class> cache = new ConcurrentHashMap<>();
23-
private List<String> moudleList = new ArrayList<>();
21+
22+
private ExecutorService executor =
23+
Executors.newFixedThreadPool(8);
24+
25+
private Map<String, Class> cache =
26+
new ConcurrentHashMap<>();
27+
28+
private List<String> moudleList =
29+
new ArrayList<>();
2430

2531

2632
private String getClassName(JarEntry entry) {
@@ -57,7 +63,6 @@ public void init() {
5763
if (className == null) {
5864
continue;
5965
}
60-
6166
try {
6267
Class<?> clazz = classLoader.loadClass(className);
6368
//缓存jar 里面的 Class 对象。

src/main/java/com/share/classloader/Test1.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ public static void main(String[] args) throws Exception {
1717
System.out.println("Hello World!");
1818
ModuleManager manager = new ModuleManager();
1919
List<String> jarList = new ArrayList<String>();
20-
jarList.add("/Users/demons/IdeaProjects/JavaCode/moduleB/target/moduleBTest-1.0-SNAPSHOT.jar");
20+
jarList.add("/Users/mac/Desktop/JavaCode/moduleB/target/moduleBTest-1.0-SNAPSHOT.jar");
2121
jarList.add(
22-
"/Users/demons/IdeaProjects/JavaCode/moduleA/target/moduleTest-1.0-SNAPSHOT.jar");
22+
"/Users/mac/Desktop/JavaCode/moduleA/target/moduleTest-1.0-SNAPSHOT.jar");
2323
manager.setMoudleList(jarList);
2424
manager.init();
2525

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.share.classloader;
2+
3+
import java.util.Random;
4+
5+
/**
6+
* @author by chenzhuo
7+
* @Description
8+
* @Date 2019/7/2 15:22
9+
**/
10+
public class Test2 {
11+
//iconst_ <-1,0,1,2 3,4,5>
12+
//iconst_m1
13+
14+
//bipush 255
15+
//invokestaic
16+
//invoke dy
17+
//anewarray
18+
public static void main(String[] args) {
19+
//anewarray class com/share/classloader/Test2_1
20+
Test2_1[] test2s = new Test2_1[10];
21+
String[] strings = new String[10];
22+
// L java/lang/Object
23+
System.err.println(test2s.getClass().getClassLoader());
24+
//newarray
25+
int[] ints = new int[10];
26+
//Ljava/lang/Object
27+
System.err.println(ints.getClass().getClassLoader());
28+
29+
}
30+
}
31+
32+
class Test2_1 {
33+
34+
static {
35+
System.err.println("Test2_1 static block");
36+
}
37+
}

0 commit comments

Comments
 (0)