Skip to content

Commit ff8d5b6

Browse files
author
jossc
committed
添加自测代码
1 parent cf74ccd commit ff8d5b6

11 files changed

Lines changed: 189 additions & 10 deletions

File tree

src/main/java/com/basics/ThreadCode/CountDownLatchTest/TestCountDownLatch.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public static void main(String []args){
2323
try {
2424
downLatch.await();
2525
System.err.println("objk");
26-
2726
// executorService.shutdownNow();
2827
} catch (InterruptedException e) {
2928
e.printStackTrace();
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
package com.basics.UnsafeTest.unsafe_voliate.model;
2-
32
/**
43
* @ClassName SuperObject
54
* @Description TODO
@@ -8,5 +7,12 @@
87
* @Version 1.0
98
**/
109
public class SuperObject {
11-
long SuperObjectLong;
10+
11+
12+
public static void main(String[] args) {
13+
int num =68;
14+
char c = (char) num;
15+
System.out.println(c);
16+
}
17+
1218
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* 7.10~7.24 Java并发编程 整理输出
3+
*/
4+
package com.concurrent.thread;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.concurrent.thread.volatileone;
2+
/**
3+
* @ClassName VolatileOne
4+
* @Author chenzhuo
5+
* @Version 1.0
6+
* @Date 2019-07-10 22:15
7+
* ; {external_word}
8+
* 0x000000010bab274f: je 0x000000010bab2793
9+
* 0x000000010bab2755: push %rsi
10+
* 0x000000010bab2756: push %rdx
11+
* 0x000000010bab2757: push %rcx
12+
* 0x000000010bab2758: push %r8
13+
* 0x000000010bab275a: push %r9
14+
* 0x000000010bab275c: movabs $0x1095aa930,%rsi ; {metadata({method} {0x00000001095aa930} 'arraycopy' '(Ljava/lang/Object;ILjava/lang/Object;II)V' in 'java/lang/System')}
15+
* 0x000000010bab2766: mov %r15,%rdi
16+
* 0x000000010bab2769: test $0xf,%esp
17+
* 0x000000010bab276f: je 0x000000010bab2787
18+
* 0x000000010bab2775: sub $0x8,%rsp
19+
* 0x000000010bab2779: callq 0x00000001070ed104 ; {runtime_call}
20+
* 0x000000010bab277e: add $0x8,%rsp
21+
* 0x000000010bab2782: jmpq 0x000000010bab278c
22+
* 0x000000010bab2787: callq 0x00000001070ed104 ; {runtime_call}
23+
* 0x000000010bab278c: pop %r9
24+
* 0x000000010bab278e: pop %r8
25+
* 0x000000010bab2790: pop %rcx
26+
* 0x000000010bab2791: pop %rdx
27+
* 0x000000010bab2792: pop %rsi
28+
* 0x000000010bab2793: lea 0x1f8(%r15),%rdi
29+
* 0x000000010bab279a: movl $0x4,0x270(%r15)
30+
* 0x000000010bab27a5: callq 0x0000000106f46d70 ; {runtime_call}
31+
* 0x000000010bab27aa: vzeroupper
32+
* 0x000000010bab27ad: movl $0x5,0x270(%r15)
33+
* 0x000000010bab27b8: lock addl $0x0,(%rsp)
34+
* 0x000000010bab27bd: cmpl $0x0,-0x45b5a57(%rip) # 0x00000001074fcd70
35+
* ; {external_word}
36+
**/
37+
public class VolatileOne {
38+
static volatile VolatileOne volatileOne;
39+
40+
public static void main(String[] args) {
41+
volatileOne = new VolatileOne();
42+
}
43+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.concurrent.thread.volatileone;
2+
3+
/**
4+
* @ClassName VolatileTwo
5+
* @Author chenzhuo
6+
* @Version 1.0
7+
* @Date 2019-07-13 22:56
8+
**/
9+
public class VolatileTwo {
10+
private int first;
11+
12+
13+
private volatile int two;
14+
15+
16+
public static void main(String[] args) {
17+
18+
19+
}
20+
21+
22+
public void write() {
23+
first = 1;
24+
two = 2;
25+
}
26+
27+
public void read() {
28+
int i = first;
29+
int j = two;
30+
31+
}
32+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.jvm.classloader.relyclass;
2+
3+
/**
4+
* @ClassName Test4
5+
* @Author chenzhuo
6+
* @Version 1.0
7+
* @Date 2019-06-30 21:35
8+
**/
9+
public class Test4 {
10+
static {
11+
System.out.println("staci block");
12+
}
13+
14+
public static void main(String[] args) {
15+
System.out.println("hello test4");
16+
}
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.jvm.classloader.relyclass;
2+
3+
/**
4+
* @ClassName Test5
5+
* @Author chenzhuo
6+
* @Version 1.0
7+
* @Date 2019-06-30 21:43
8+
**/
9+
public class Test5 {
10+
11+
public static void main(String[] args) {
12+
/*String[] strings = new String[10];
13+
System.out.println(strings.getClass());*/
14+
int[] ints = new int[10];
15+
System.out.println(ints.getClass());
16+
}
17+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.jvm.classloader.relyclass;
2+
3+
import java.util.Random;
4+
5+
/**
6+
* @ClassName Test6
7+
* @Author chenzhuo
8+
* @Version 1.0
9+
* @Date 2019-06-30 22:11
10+
**/
11+
public class Test6 {
12+
13+
public static void main(String[] args) {
14+
System.out.println(Test6_1.i);
15+
}
16+
}
17+
18+
class Test6_1 {
19+
public static final int i = new Random().nextInt(100);
20+
21+
static {
22+
System.out.println("test6_1 static block");
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.jvm.classloader.relyclass;
2+
3+
/**
4+
* @ClassName Test7
5+
* @Author chenzhuo
6+
* @Version 1.0
7+
* @Date 2019-06-30 22:35
8+
**/
9+
public class Test7 {
10+
public static void main(String[] args) {
11+
System.out.println(Test7_2.i);
12+
}
13+
}
14+
class Test7_1{
15+
public static int i =5;
16+
static {
17+
System.out.println("Test7_1 static block");
18+
}
19+
}
20+
class Test7_2 extends Test7_1{
21+
static {
22+
System.out.println("Test7_2 static block");
23+
}
24+
}

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,28 @@
1313
**/
1414
public class TestOne {
1515

16-
static {
17-
System.err.println("classPath :" + TestOne.class.getClassLoader());
16+
public static void main(String[] args) {
17+
TestChild testChild = new TestChild();
1818
}
19+
}
1920

20-
public static void main(String[] args) {
21+
class TestOneParent {
22+
/**
23+
* 如果是final static 修饰,在编译期间就会确定和初始化值,如果有子类或者自身引用 不会初始化static
24+
*/
25+
public static final String sh = "skr skr";
26+
27+
public static String s = "Hello word";
2128

29+
static {
30+
System.out.println("this static block");
2231
}
32+
2333
}
2434

35+
class TestChild extends TestOneParent {
36+
public static String skr = "skr";
37+
static {
38+
System.out.println("child one static block");
39+
}
40+
}

0 commit comments

Comments
 (0)