Switch to C++11 threading API

This removes dependencies on the POSIX threads API and uses exclusively
the C++11 standard for multi-threading. This is not complete yet,
compilation flags still need to be worked out and tested for MacOSX and
Windows.