This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|----------------------------------------------------------------------------------------|--------------------| | |
| Object Header (64 bits) | State | | |
|-------------------------------------------------------|--------------------------------|--------------------| | |
| Mark Word (32 bits) | Klass Word (32 bits) | | | |
|-------------------------------------------------------|--------------------------------|--------------------| | |
| identity_hashcode:25 | age:4 | biased_lock:1 | lock:2 | OOP to metadata object | Normal | | |
|-------------------------------------------------------|--------------------------------|--------------------| | |
| thread:23 | epoch:2 | age:4 | biased_lock:1 | lock:2 | OOP to metadata object | Biased | | |
|-------------------------------------------------------|--------------------------------|--------------------| | |
| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void enumSwitch(); | |
Code: | |
0: getstatic #2 // Field DayOfWeek.FRIDAY:LDayOfWeek; | |
3: astore_0 | |
4: iconst_0 | |
5: istore_1 | |
6: getstatic #3 // Field Switch$1.$SwitchMap$DayOfWeek:[I | |
9: aload_0 | |
10: invokevirtual #4 // Method DayOfWeek.ordinal:()I | |
13: iaload |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sun.misc.Cleaner; | |
import sun.misc.Unsafe; | |
import sun.nio.ch.DirectBuffer; | |
import java.lang.reflect.Field; | |
import java.nio.ByteBuffer; | |
// How to run: | |
// struct: javac ObjectVsStruct.java && java ObjectVsStruct struct | |
// object: javac ObjectVsStruct.java && java ObjectVsStruct object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BiasedLocking { | |
private static final int LOOP_COUNT = 10000000; // 10 million | |
public static void main(final String[] args) { | |
incrementCounter(); | |
} | |
public static void incrementCounter() { | |
final long startTime = System.currentTimeMillis(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bash ./configure | |
make all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean isPrime(final int number) { | |
return number > 1 && | |
IntStream.rangeClosed(2, (int) Math.sqrt(number)) | |
.noneMatch(index -> number % index == 0); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AssemblyMain { | |
public static void main(String[] args) { | |
int number = 100000; | |
System.out.println("Calculating SUM of the squares of 1 to " + number); | |
long sum = sum(number); | |
System.out.println("SUM: " + sum); | |
} |
NewerOlder