-------------------------------------------------------------------------------- Now i am using C++ try to create a Thread class, and used by main function. in the main function i will create 2 threads and 1 critical section and 1 com port handle, i want the 2 threads share the same handle and critical section. in the construction of thread, i pass the address of handle and critical section in. In the function of thread i will try to enter the critical section and do something. But now the condition i met is that neither of the 2 threads can enter the critical section. If i don't care about the critical section, neither of them can use the send thing to com port handle. So is there anyone met this condition before? what's the problem? Thanks a lot for your help in advance...
stans80
Posts
-
About OOP thread programming -
Help! in C++ How to implement 2 classes share one classME!
-
Help! in C++ How to implement 2 classes share one classThe code will work on i create the classes a1 and b1, but now they wont be created by me, it will be created by others, they only pass in one parameter, like A a1 = new A(1), C c1, B b1 = new B(1), then i should know c1 is shared by a1 and b1. that means b1 will go to find c1.
-
Help! in C++ How to implement 2 classes share one classnow i have something as following: A a* = new A(); B b* = new B(); there is a class C created in the constructor of A, but i want the b class also can use this C class. for example: A a1* = new A(); //c class will be created (we call it c1 for differencial) A a2* = new A(); //c class will be created (we call it c2 for differencial) B b1* = new B(); // I want b1 share the c1 with a1, but not use c2 B b2* = new B(); // I want b2 share the c2 with a2, but not use c1 Is there anyway i can do this? Thanks a lot in advance.
-
Help! about 2 threads share one com portNow i have one serial com port, and i want it been shared by 2 threads. Now i am using the binary semaphore to control it. I want to ask is it good? or is it good to use the critical section? Can any body help me compare these method to let me see which one is better? Thanks
-
Thread Terminationpls refer to the following url, http://www.codeguru.com/Cpp/misc/misc/threadsprocesses/article.php/c3747/[^] I think it is quite clear.