Move implementation for threads to Rust

This binds to the appropriate pthreads_* and Windows specific functions
and calls them from Rust. This allows for removal of the C++ support
code for threads.

Fixes #10162
auto merge of #10290 : dbussink/rust/thread_in_rust, r=alexcrichton

This binds to the appropriate pthreads_* and Windows specific functions
and calls them from Rust. This allows for removal of the C++ support
code for threads.

This needs to be reviewed for the Windows parts, I've tested on OS X and Linux.

Fixes #10162