Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   Threading with Hashtable class (http://www.programmingforums.org/showthread.php?t=12861)

ssrun Mar 23rd, 2007 3:40 PM

Threading with Hashtable class
 
Hi,

I'm trying to use a Hashtable object with my multi-threaded server. Basically, I have a ServerApp object that listens for client connections and when a client connects it spawns a new thread to handle the connection.

The thread takes a reference to the socket object and the Hashtable object that is a member of the ServerApp object.

When I try to do any operations (specifically containsKey() and put()) on the Hashtable object from the thread the program seems to hang on that line as if it is waiting for the Hashtable to be unlocked.

I've tried declaring the method synchronized on the method in the thread that performs operations on the Hashtable but it seems to make no difference. According to the API, the Hashtable is already synchronized and shouldn't need that keyword but I put it in there just in case.

Any help is appreciated.

ssrun Mar 23rd, 2007 7:41 PM

I've figured out the problem. The hashtable reference was actually null and I had a catch for a general exception that did nothing inside my infinite thread loop.


All times are GMT -5. The time now is 2:20 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC