So I've got a programming assignment that just multiplies two matrices together, and stores the result in a third. Supposed to be done using threads, but I have no idea how to start. I understand what a thread is, but I guess I just don't know how to actually use threads when programming. I've hit this wall in my head where I can't even comprehend what's supposed to happen. Any tips?
you can use pthreads or if you have a C++11 capable compiler (clang 3.1 later, gcc 4.7.1 later, Visual Studio 2012 etc) then you can use the built in threads of C++11 std.
Here is how threads in C++11 are created
1 2 3 4 5 6
std::thread t1 (thread_function, thread_argument);
//You can pass multiple arguments to the thread like std::thread t1 (thread_function, int_argument, vector_argumane, object_argument );
//Some code in main thread
t1.join(); //wait for the thread to complete
Ah thanks these links are great! I understand what the program needs to get done, I was just having trouble of actually using the threads. We covered threads in theory but not with how they work at all. Didn't know that you created a thread and passed it a function to perform. Not really sure what I was thinking for how threads worked -_-