More advanced thread testing code