fix a bug for thread