Refactor the multi-threading api to support using custom user-provided thread factory instead of always spawning POSIX Threads.