Revert "Revert "Implemented pthread for MinGW. Added ThreadLocalPtr.""

This reverts commit 85af949aa09671d1967369605fd2d80548d01805.