[PATCH 2/7] threading: Add basic threading infrastructure