WINAPI thread problem
I've been working on this project for a long time now and can't seem to find how this is done.
c++ language under windows.
I created 4 threads. Inside one of the threads I want to call another thread funtion. How is this done?? Cause it does not seem to work like other threads.
Thanks so much in advance.
DWORD WINAPI R1 (LPVOID)
cout << "R1 in CS." << endl;
cout << readcount << "Readers in CS." << endl;
cout << writecount << "Wrtiers in CS." << endl;
//want to call a thread here. example R#2.
return (DWORD) 0;
Functions don't belong to a thread of course, you can generally call a function from whatever thread, it's just that it will execute in the thread that calls it.
Are you actually wanting to have one thread cause a different thread to call a particular function? Then are you perhaps wanting to wait until that other thread has finished that call?
Or perhaps you're wanting to call a member function but the thread proc is a static method so it obviously wont let you?
Can you show us what you've tried and what compiler errors you get?
The code you've posted already looks rather dubious. That spin-lock locking mechanism just doesn't sit well with me.
Could you fix the indentation as well please?