Code related to threads and the high level thread API