Implement thread library