Move platform-specific threading stuff to threading.h.