Threaded matrix multiplication in C++