当前位置: 首页>>代码示例>>Java>>正文


Java ClassLayout.parseInstance方法代码示例

本文整理汇总了Java中org.openjdk.jol.info.ClassLayout.parseInstance方法的典型用法代码示例。如果您正苦于以下问题:Java ClassLayout.parseInstance方法的具体用法?Java ClassLayout.parseInstance怎么用?Java ClassLayout.parseInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openjdk.jol.info.ClassLayout的用法示例。


在下文中一共展示了ClassLayout.parseInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.openjdk.jol.info.ClassLayout; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    out.println(VM.current().details());

    TimeUnit.SECONDS.sleep(6);

    final A a = new A();

    ClassLayout layout = ClassLayout.parseInstance(a);

    out.println("**** Fresh object");
    out.println(layout.toPrintable());

    synchronized (a) {
        out.println("**** With the lock");
        out.println(layout.toPrintable());
    }

    out.println("**** After the lock");
    out.println(layout.toPrintable());
}
 
开发者ID:tianshuang,项目名称:jol-samples,代码行数:21,代码来源:JOLSample_13_BiasedLocking.java

示例2: main

import org.openjdk.jol.info.ClassLayout; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    out.println(VM.current().details());

    final A a = new A();

    ClassLayout layout = ClassLayout.parseInstance(a);

    out.println("**** Fresh object");
    out.println(layout.toPrintable());

    synchronized (a) {
        out.println("**** With the lock");
        out.println(layout.toPrintable());
    }

    out.println("**** After the lock");
    out.println(layout.toPrintable());
}
 
开发者ID:tianshuang,项目名称:jol-samples,代码行数:19,代码来源:JOLSample_12_ThinLocking.java

示例3: main

import org.openjdk.jol.info.ClassLayout; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    out.println(VM.current().details());

    PrintWriter pw = new PrintWriter(System.out, true);

    Object o = new Object();

    ClassLayout layout = ClassLayout.parseInstance(o);

    long lastAddr = VM.current().addressOf(o);
    pw.printf("Fresh object is at %x%n", lastAddr);

    int moves = 0;
    for (int i = 0; i < 100000; i++) {
        long cur = VM.current().addressOf(o);
        if (cur != lastAddr) {
            moves++;
            pw.printf("*** Move %2d, object is at %x%n", moves, cur);
            out.println(layout.toPrintable());
            lastAddr = cur;
        }

        // make garbage
        for (int c = 0; c < 10000; c++) {
            sink = new Object();
        }
    }

    pw.close();
}
 
开发者ID:tianshuang,项目名称:jol-samples,代码行数:31,代码来源:JOLSample_19_Promotion.java

示例4: main

import org.openjdk.jol.info.ClassLayout; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    out.println(VM.current().details());

    final A a = new A();

    ClassLayout layout = ClassLayout.parseInstance(a);

    out.println("**** Fresh object");
    out.println(layout.toPrintable());

    Thread t = new Thread(new Runnable() {
        @Override
        public void run() {
            synchronized (a) {
                try {
                    TimeUnit.SECONDS.sleep(10);
                } catch (InterruptedException e) {
                    return;
                }
            }
        }
    });

    t.start();

    TimeUnit.SECONDS.sleep(1);

    out.println("**** Before the lock");
    out.println(layout.toPrintable());

    synchronized (a) {
        out.println("**** With the lock");
        out.println(layout.toPrintable());
    }

    out.println("**** After the lock");
    out.println(layout.toPrintable());

    System.gc();

    out.println("**** After System.gc()");
    out.println(layout.toPrintable());
}
 
开发者ID:tianshuang,项目名称:jol-samples,代码行数:44,代码来源:JOLSample_14_FatLocking.java

示例5: main

import org.openjdk.jol.info.ClassLayout; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    out.println(VM.current().details());

    final A a = new A();

    ClassLayout layout = ClassLayout.parseInstance(a);

    out.println("**** Fresh object");
    out.println(layout.toPrintable());

    out.println("hashCode: " + Integer.toHexString(a.hashCode()));
    out.println();

    out.println("**** After identityHashCode()");
    out.println(layout.toPrintable());
}
 
开发者ID:tianshuang,项目名称:jol-samples,代码行数:17,代码来源:JOLSample_15_IdentityHashCode.java

示例6: layout

import org.openjdk.jol.info.ClassLayout; //导入方法依赖的package包/类
public static ClassLayout layout(Object instance) {
    return ClassLayout.parseInstance(instance);
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_10,代码行数:4,代码来源:ObjectLayer.java


注:本文中的org.openjdk.jol.info.ClassLayout.parseInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。