-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo2.java
More file actions
23 lines (19 loc) · 735 Bytes
/
Copy pathDemo2.java
File metadata and controls
23 lines (19 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import org.openjdk.jol.info.ClassLayout;
/**
* @author xjn
* @since 2020-02-29
*/
public class Demo2 {
private static Object object = new Object();
public static void main(String[] args) throws Exception {
System.out.println(Integer.toHexString(object.hashCode()));
System.out.println(ClassLayout.parseInstance(object).toPrintable() + " ******");
new Thread(() -> {
synchronized (object) {
System.out.println(ClassLayout.parseInstance(object).toPrintable() + "++++");
}
}).start();
System.out.println(Integer.toHexString(object.hashCode()));
System.out.println(ClassLayout.parseInstance(object).toPrintable() + "--------");
}
}