I have function A and function B. I want function A and B to be synchronized within object O. Multiple threads will be accessing object O. When function B is running, no function As will be running and vice-versa.
Function A should not stop another function A from running. Simply having a lock for A and B will cause one A to lock out another A. How do you synchronize A and B together without locking multiple threads on A?
I want function A and B to be synchronized within object O...
If functions A and B are guaranteed to run at different times,
controlled by other factors, apparently, why do you want them
to be synchronized?
BEE MBA PMP SCJP-6
Joined: Mar 18, 2007
Henry, a read/write lock seems to be exactly what I am looking for, thanks!
I have an object O that establishes a connection with a server and requests are rean through that object. To not have each thread have performance hit of initializing a connection, I am caching that object and having each thread simply call the get request (object O is thread safe to handle simultaneous get requests). My code needs to reinitialize the connection after X get requests which means when one thread is reinitializing the connection, no get requests should proceed. So, I think a read/write lock will be perfect for this.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com