fix a bug in thread simulator