26 lines
968 B
Java
26 lines
968 B
Java
//package concurrent.thread;
|
|
//
|
|
//import org.openjdk.jol.info.ClassLayout;
|
|
//
|
|
///**
|
|
// * @description: 锁升级 TODO
|
|
// * @author: wangyl
|
|
// * @date: 2024/6/21
|
|
// */
|
|
//public class SyncronizedLevelUp {
|
|
// public static void main(String[] args) throws InterruptedException {
|
|
// Object o = new Object();
|
|
// System.out.println("还没有进入到同步块");
|
|
// System.out.println("markword:" + ClassLayout.parseInstance(o).toPrintable());
|
|
// //默认JVM启动会有一个预热阶段,所以默认不会开启偏向锁
|
|
// Thread.sleep(5000);
|
|
// Object b = new Object();
|
|
// System.out.println("还没有进入到同步块");
|
|
// System.out.println("markword:" + ClassLayout.parseInstance(b).toPrintable());
|
|
// synchronized (o) {
|
|
// System.out.println("进入到了同步块");
|
|
// System.out.println("markword:" + ClassLayout.parseInstance(o).toPrintable());
|
|
// }
|
|
// }
|
|
//}
|