This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.IOException; | |
| import java.lang.reflect.Field; | |
| import java.util.HashSet; | |
| import java.util.concurrent.*; | |
| import java.util.concurrent.atomic.AtomicInteger; | |
| /** | |
| * -XX:+PrintGCDetails | |
| * jcmd PID GC.run 强制来一发GC. | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # JCStress repo, version 0.5 | |
| hg clone http://hg.openjdk.java.net/code-tools/jcstress/ jcstress | |
| cd jcstress | |
| hg up 0.5 | |
| # 1) jcstress-sample | |
| # source code: http://hg.openjdk.java.net/code-tools/jcstress/file/3c94746a6abf/jcstress-samples/src/main/java/org/openjdk/jcstress/samples | |
| # JMM & Concurrent samples also on: https://gist.github.com/liufor/f08495f0596ddf98a3542307b72f080f | |
| # maven: https://mvnrepository.com/artifact/org.openjdk.jcstress/jcstress-samples |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Copyright (c) 2016, Red Hat Inc. | |
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| * | |
| * This code is free software; you can redistribute it and/or modify it | |
| * under the terms of the GNU General Public License version 2 only, as | |
| * published by the Free Software Foundation. Oracle designates this | |
| * particular file as subject to the "Classpath" exception as provided | |
| * by Oracle in the LICENSE file that accompanied this code. | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 简单例子验证 volatile 的,不用JCStress. | |
| */ | |
| public class SyncDeadLock { | |
| public static void main(String[] args) { | |
| DataRace dataRace = new DataRace(); | |
| Thread[] threads = new Thread[100]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.lang.annotation.Inherited; | |
| import java.lang.annotation.Retention; | |
| import java.lang.annotation.RetentionPolicy; | |
| @Inherited | |
| @Retention(RetentionPolicy.RUNTIME) | |
| public @interface AnnotationX { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Sync implements Runnable { | |
| int n; | |
| public static void main(String[] args) { | |
| Sync sync = new Sync(); | |
| new Thread(sync, "Sync1").start(); | |
| new Thread(sync, "Sync2").start(); | |
| new Thread(sync, "Sync3").start(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import io.undertow.*; | |
| import io.undertow.server.*; | |
| import io.undertow.util.*; | |
| public class HelloWorldServer { | |
| public static void main(final String[] args) { | |
| Undertow server = Undertow.builder() | |
| .addHttpListener(8080, "localhost") | |
| .setHandler(new HttpHandler() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import jdk.nashorn.internal.runtime.ECMAException; | |
| import sun.misc.Launcher; | |
| import sun.misc.URLClassPath; | |
| import java.lang.reflect.Field; | |
| import java.net.URL; | |
| import java.net.URLClassLoader; | |
| /** | |
| * 简单打印出 Boot、System、Ext 3个 classloader 的 对应的 classpath 的 URLs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class LocalVariablesPrimitiveTypeLiteralBytecodeDemo { | |
| public static void main(String[] args) throws InterruptedException { | |
| boolean booltrue = true; //ICONST_1 | |
| boolean boolfalse = false; //ICONST_0 | |
| //byte、short、char、int 局部变量根据值大小不同而由不同的 | |
| //byte 范围 [-128,127], ICONST_X 、BIPUSH |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data 1879 | |
| database 1245 | |
| system 1196 | |
| write 976 | |
| node 751 | |
| page 744 | |
| example 663 | |
| time 600 | |
| need 586 | |
| read 566 |