P
Peter
Hi
In a multi-threaded application I need to keep track of request-counts
for various "users". That is, when a user makes a request to my
application I need to increment a counter to track the number of times
the user has made a request.
But a "user" is more than a single entity, and the same user can be
calling my application simultaneously.
How do I keep track of a user's requests? If I use a simple Hashtable
(with the users' unique ids as keys) to contain the counts, when I get
the count from the Hashtable to update it, the same user could be
making another request simultaneously, and the counts will not be
accurate.
I don't want to lock the entire Hashtable, because I am worried that
will badly affect performance - as if several different users are
calling simultaneously then they will have to wait for each other.
Any ideas to how I can implement a counter for user requests?
Thanks,
Peter
In a multi-threaded application I need to keep track of request-counts
for various "users". That is, when a user makes a request to my
application I need to increment a counter to track the number of times
the user has made a request.
But a "user" is more than a single entity, and the same user can be
calling my application simultaneously.
How do I keep track of a user's requests? If I use a simple Hashtable
(with the users' unique ids as keys) to contain the counts, when I get
the count from the Hashtable to update it, the same user could be
making another request simultaneously, and the counts will not be
accurate.
I don't want to lock the entire Hashtable, because I am worried that
will badly affect performance - as if several different users are
calling simultaneously then they will have to wait for each other.
Any ideas to how I can implement a counter for user requests?
Thanks,
Peter