Better typing for ThreadAPI