Make threading work on windows phone

Since recently, the threading code is no longer optional but is always enabled. This adds the necessary support for building the threading library for Windows Phone.