Test codes for threads