Skip to content

Instantly share code, notes, and snippets.

View yanglikun's full-sized avatar
😀

yanglikun yanglikun

😀
View GitHub Profile
/**
* 使用如下命令运行:
* java -XX:+UseBiasedLocking //开启偏向锁,如果关闭用 -XX:-UseBiasedLocking
* -XX:+UnlockDiagnosticVMOptions //打开诊断模式,才能使用PrintBiasedLockingStatistics打印偏向锁信息
* -XX:+PrintBiasedLockingStatistics//在C1中打印偏向锁信息
* -XX:TieredStopAtLevel=1 //设置JIT编译器为C1
* -XX:BiasedLockingStartupDelay=0 //关闭偏向锁启动延时,jdk6有4秒延时,4秒内用lightweight,4秒后才开始启动biased lock
* BiasedLockAndHashCodeTest
*/
public class BiasedLockAndHashCodeTest {
@yanglikun
yanglikun / ObjectHeader32.txt
Created February 27, 2019 02:09 — forked from arturmkrtchyan/ObjectHeader32.txt
Java Object Header
|----------------------------------------------------------------------------------------|--------------------|
| 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 |
|-------------------------------------------------------|--------------------------------|--------------------|
|
<?php
phpinfo();
?>
@yanglikun
yanglikun / gist:b4741b98237c117eba609fb08d673f68
Created August 7, 2018 13:31
smart_concrat_example.sol
pragma solidity ^0.4.0;
contract Counter{
uint public count=10;
function inc(uint num) public returns (uint){
return count+=num;
}
}
contract CallCounter{
uint public count=20;
function callByAddr(address addr) public returns(uint){
@yanglikun
yanglikun / freemarker 静态类调用
Created February 5, 2018 07:27
freemarker 静态类调用
public class FreemarkerModelInterceptor implements HandlerInterceptor {
private static final Logger logger = LoggerFactory.getLogger(FreemarkerModelInterceptor.class);
private Map<String, String> utilClasses;
private TemplateHashModel staticModels;
public FreemarkerModelInterceptor() {
BeansWrapperBuilder builder = new BeansWrapperBuilder(Configuration.VERSION_2_3_26);
@yanglikun
yanglikun / genericExtendAndSuper.java
Created September 3, 2017 06:52
genericExtendAndSuper
List<? extends Number> extendsList = null;
List<? super Number> superList = null;
List<Object> objList = null;
List<Number> numberList = null;
List<Integer> integerList = null;
//extendsList=objList; //compile error
extendsList = numberList;
extendsList = integerList;
@yanglikun
yanglikun / genericRunTimeError.java
Created September 2, 2017 05:28
编译没错,运行时出错。和泛型有关
class A<T extends Comparable & List> {
public void test(T t) {
t.add("cc");
}
}
public class Test {
public static void main(String[] args) {
@yanglikun
yanglikun / Suppliers.memoizeWithExpiration
Created August 29, 2017 01:58
Suppliers.memoizeWithExpiration
DateTime dateTime = DateTime.now().plusSeconds(2);
Supplier<String> supplier = Suppliers.memoizeWithExpiration(() -> {
DateTime now = DateTime.now();
if (now.getSecondOfDay() == dateTime.getSecondOfDay()) {
throw new RuntimeException("haha~~" + now.toString("yyyy-MM-hh HH:mm:ss"));
}
return "time:" + now.toString("yyy-MM-dd HH:mm:ss");
}, 1, TimeUnit.SECONDS);
for (int i = 0; i < 10; i++) {
try {
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="JD_PLT_EXT" />
<inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
<option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
<option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />
</inspection_tool>
<inspection_tool class="MissortedModifiers" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_requireAnnotationsFirst" value="true" />
</inspection_tool>
<code_scheme name="JD_PLT_EXT_codeStyle">
<option name="LINE_SEPARATOR" value="&#xA;" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="100" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="100" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
</option>
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="" withSubpackages="true" static="true" />