First thread related code.