A question about thread programming
-
Here is a class which I want to use in a multi-threaded program: class threadclass { public: void A(); void B(); }; void threadclass::A() { B(); } void threadclass::B() { } UINT WINAPI threadproc(LPVOID lpData) { threadclass xx; xx.A(); return 0; } I use it like this: CWinThread *pThread=AfxBeginThread(threadproc,NULL); Will there be some error occured? Is the class thread-safe? :confused: Law is meaningless without chaos. Chaos without Law is equal to destruction. Chaos and Law create our rich and colorful world.
-
Here is a class which I want to use in a multi-threaded program: class threadclass { public: void A(); void B(); }; void threadclass::A() { B(); } void threadclass::B() { } UINT WINAPI threadproc(LPVOID lpData) { threadclass xx; xx.A(); return 0; } I use it like this: CWinThread *pThread=AfxBeginThread(threadproc,NULL); Will there be some error occured? Is the class thread-safe? :confused: Law is meaningless without chaos. Chaos without Law is equal to destruction. Chaos and Law create our rich and colorful world.
Aren't you missing anything in the exposition of your problem? The class is trivially thread safe, basically because it does nothing. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo