java基础 并发测试代码

This commit is contained in:
wyl
2024-07-01 00:28:32 +08:00
parent da0e11337c
commit 30d826bb8e
23 changed files with 1258 additions and 25 deletions
@@ -0,0 +1,25 @@
//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());
// }
// }
//}