thread calculating