java基础 并发测试代码
This commit is contained in:
@@ -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());
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user