I am working (for my study) on a multithreaded server program. The server is supposed to respond to a client request (in the form of a character) with a response, depending on the value of the request character. I need to store all client activity in a table, which I chose to be a Hashtable. The hashtable keeps an entry for each client, with info about the last request and the last response sent to the client. At each request, I retrieve the client entry from the hashtable with
ClientEntry cEntryIn = (ClientEntry) clientTable.get(client);
Then I check if this entry == null. If so, I create a new client entry, and write it to the hashtable with a put command.
When the entry not equals null, I need to update a few fields in the client entry, and write it back again to the client table. However, everything works fine with one client, but as soon as other clients become active, it looks as if the fields that I am writing to one client in some cases are read back with another client entry. I have looked and looked, and cannot figure it out.
Anybody experience with hashtables, who recognize this problem? Or maybe just some programming enthusiast who likes to dive into a bug?
I would be happy with any good ideas.
Wini
ClientEntry cEntryIn = (ClientEntry) clientTable.get(client);
Then I check if this entry == null. If so, I create a new client entry, and write it to the hashtable with a put command.
When the entry not equals null, I need to update a few fields in the client entry, and write it back again to the client table. However, everything works fine with one client, but as soon as other clients become active, it looks as if the fields that I am writing to one client in some cases are read back with another client entry. I have looked and looked, and cannot figure it out.
Anybody experience with hashtables, who recognize this problem? Or maybe just some programming enthusiast who likes to dive into a bug?
I would be happy with any good ideas.
Wini