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
#!/usr/bin/env bash | |
CMD=java | |
JAVA_VER=$(java -version 2>&1 | grep -i version | sed 's/.*version ".*\.\(.*\)\..*"/\1/; 1q') | |
if [ ${JAVA_VER} -lt 8 ]; then | |
echo "JDK版本过低,请使用1.8及以上版本" | |
exit 1 | |
fi |
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 CacheLineEffect { | |
//考虑一般缓存行大小是64字节,一个 long 类型占8字节 | |
static long[][] arr; | |
public static void main(String[] args) { | |
arr = new long[1024 * 1024][]; | |
for (int i = 0; i < 1024 * 1024; i++) { | |
arr[i] = new long[8]; | |
for (int j = 0; j < 8; j++) { | |
arr[i][j] = 0L; |
OlderNewer