File tree Expand file tree Collapse file tree
concurrent/cyclicbarrierlearn/map Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ public class HashMapTest {
1515
1616 public static void main (String [] args ) throws InterruptedException {
1717 Thread t1 = new Thread (() -> {
18- for (int i = 1 ; i <= 100000 ; i ++) {
18+ for (int i = 1 ; i <= 100 ; i ++) {
1919 int result = i ;
2020 new Thread (() -> hashMap .put (result , result ), "cc" + i ).start ();
2121 }
@@ -24,7 +24,7 @@ public static void main(String[] args) throws InterruptedException {
2424 t1 .start ();
2525 Thread .sleep (5000 );
2626 System .err .println ("11" );
27- for (int i = 1 ; i <= 100000 ; i ++) {
27+ for (int i = 1 ; i <= 100 ; i ++) {
2828 Integer value = (Integer ) hashMap .get (i );
2929 if (value == null ) {
3030 System .out .println (i + "数据丢失" );
Original file line number Diff line number Diff line change 1+ package com .datastructure ;
2+
3+ /**
4+ * @author by chenzhuo
5+ * @Description
6+ * @Date 2019/7/8 15:14
7+ **/
8+ public class Iphone {
9+ int length = 138 ;
10+ int width = 67 ;
11+ int height = 7 ;
12+ int weight = 143 ;
13+ int ram = 2 ;
14+ int rom = 16 ;
15+ int pixel = 1200 ;
16+
17+ public static void main (String [] args ) {
18+ System .err .println ("args:" + args .length );
19+ }
20+ }
Original file line number Diff line number Diff line change 1+ package com .enums ;
2+
3+ /**
4+ * @author by chenzhuo
5+ * @Description
6+ * @Date 2019/7/8 16:55
7+ **/
8+ public class SwitchEnumTest {
9+ public static void main (String [] args ) {
10+
11+ TestEnums testEnums = TestEnums .A ;
12+ System .err .println (testEnums .ordinal ());
13+ switch (testEnums ) {
14+ default :
15+ break ;
16+ case A :
17+ System .err .println ("hello word" );
18+ break ;
19+ case H :
20+ System .err .println ("hello word" );
21+ break ;
22+ }
23+
24+
25+ }
26+ }
Original file line number Diff line number Diff line change 1+ package com .jvm .bytecode ;
2+
3+ /**
4+ * @author by chenzhuo
5+ * @Description
6+ * @Date 2019/7/9 10:55
7+ **/
8+ public class A {
9+
10+
11+ }
12+
13+ class C {
14+ static {
15+ System .out .println ("C init" );
16+ }
17+
18+ public C () {
19+ System .out .println ("C Instance" );
20+ }
21+
22+ }
23+
24+ class B extends C {
25+ static {
26+ System .out .println ("B init" );
27+ }
28+
29+ public B () {
30+ System .out .println ("B Instance" );
31+ }
32+ public static void main (String [] args ) {
33+ C c = new B ();
34+ }
35+
36+ }
37+
Original file line number Diff line number Diff line change 1+ package com .jvm .bytecode ;
2+
3+ /**
4+ * @author by chenzhuo
5+ * @Description 可变参数
6+ * @Date 2019/7/9 14:12
7+ **/
8+ abstract class Changeable {
9+ /**
10+ * 有意思的代码
11+ *
12+ * @param obj
13+ * @param args
14+ */
15+ abstract void invoke (Object obj , Object ... args );
16+
17+ /**
18+ * 有意思的代码2
19+ *
20+ * @param s s
21+ * @param object obj
22+ * @param args args
23+ */
24+ abstract void invoke (String s , Object object , Object ... args );
25+ }
Original file line number Diff line number Diff line change 1+ package com .jvm .bytecode ;
2+
3+ /**
4+ * @author by chenzhuo
5+ * @Description
6+ * @Date 2019/7/9 14:13
7+ **/
8+ public class ChangeableSubclass extends Changeable {
9+
10+ @ Override
11+ void invoke (Object obj , Object ... args ) {
12+ System .err .println ("this is method first" );
13+ }
14+
15+ @ Override
16+ void invoke (String s , Object object , Object ... args ) {
17+ System .err .println ("this is method second" );
18+ }
19+
20+ void test1 (Object object , Object ib ) {
21+ System .err .println ("method first" );
22+
23+ }
24+
25+ void test1 (String hello , Object o ) {
26+ System .err .println ("method second" );
27+
28+ }
29+
30+ public static void main (String [] args ) {
31+ /* Changeable changeable = new ChangeableSubclass();
32+ changeable.invoke(null, 1);
33+ changeable.invoke(null, 1, 2);
34+ changeable.invoke(null, new Object[]{1});*/
35+ ChangeableSubclass subclass = new ChangeableSubclass ();
36+ subclass .test1 (1 , 1 );
37+ subclass .test1 (111 , 11 );
38+
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ package com .jvm .bytecode ;
2+
3+ /**
4+ * @author by chenzhuo
5+ * @Description
6+ * @Date 2019/7/9 16:24
7+ **/
8+ public interface Clientele {
9+ boolean isVIP ();
10+ }
Original file line number Diff line number Diff line change 1+ package com .jvm .bytecode ;
2+
3+ import java .util .Random ;
4+
5+ /**
6+ * @author by chenzhuo
7+ * @Description
8+ * @Date 2019/7/9 16:25
9+ **/
10+ public class ClienteleImpl {
11+
12+ public double after (double h , Clientele i ) {
13+ return h * 0.8d ;
14+ }
15+ }
16+
17+ class ClinetChild extends ClienteleImpl implements Clientele {
18+
19+ @ Override
20+ public double after (double h , Clientele i ) {
21+ // invokeinterface #2, 1
22+ // InterfaceMethod com/jvm/bytecode/Clientele.isVIP:()Z
23+ if (i .isVIP ()) {
24+ //invokestatic
25+ return h * problem ();
26+ }
27+ //invokespecial
28+ return super .after (h , i );
29+
30+ }
31+
32+ @ Override
33+ public boolean isVIP () {
34+ return true ;
35+ }
36+
37+ public static double problem () {
38+ //invokespecial, 然后 invokevirtual
39+ return new Random ().nextDouble ()
40+ + 0.8d ;
41+ }
42+
43+ public static void main (String [] args ) {
44+ ClinetChild clinetChild = new ClinetChild ();
45+ clinetChild .after (100 ,clinetChild );
46+ }
47+ }
Original file line number Diff line number Diff line change 1+ package com .jvm .bytecode ;
2+
3+ /**
4+ * @author by chenzhuo
5+ * @Description
6+ * @Date 2019/7/8 18:26
7+ **/
8+ public class Initializer {
9+ static int a ;
10+ static int b ;
11+ static {
12+ a = 1 ;
13+ b = 2 ;
14+ }
15+
16+ public static void main (String [] args ) {
17+
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ package com .jvm .bytecode ;
2+
3+ /**
4+ * @author by chenzhuo
5+ * @Description
6+ * @Date 2019/7/9 14:06
7+ **/
8+ abstract class Passenger {
9+ abstract void passThroughImmigration ();
10+
11+ @ Override
12+ public String toString () {
13+ return super .toString ();
14+ }
15+ }
16+
17+ class Fore extends Passenger {
18+
19+ @ Override
20+ void passThroughImmigration () {
21+ System .out .println ("do some" );
22+ }
23+ }
24+
25+ class Chinese extends Passenger {
26+
27+ @ Override
28+ void passThroughImmigration () {
29+ System .out .println ("chinese do some" );
30+ }
31+
32+ void visitDutyFreeShop () {
33+ System .out .println ("chinese do visitDutyFreeShop" );
34+ }
35+
36+ public static void main (String [] args ) {
37+ Passenger passenger = new Chinese ();
38+ passenger .passThroughImmigration ()
39+ ;
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments