fix HAS_REF=true records with HAS_REF_COUNT=0
dynamic thread number