Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 23rd, 2007, 2:40 PM   #1
ssrun
Newbie
 
Join Date: Aug 2006
Posts: 20
Rep Power: 0 ssrun is on a distinguished road
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 is offline   Reply With Quote
Old Mar 23rd, 2007, 6:41 PM   #2
ssrun
Newbie
 
Join Date: Aug 2006
Posts: 20
Rep Power: 0 ssrun is on a distinguished road
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.
ssrun is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wierd compile Error. Need help please. Keiyentai Java 7 Aug 19th, 2006 1:35 AM
Question about analyzing 6 million records Arla C# 11 Jun 22nd, 2006 3:02 PM
What is: "Oriented programming (OO)?" BrinyCode C++ 12 Nov 22nd, 2005 7:40 AM
User Input for Number Format ericelysia1 Java 0 Jul 21st, 2005 3:41 PM
MFC/OpenGL: problem with 'Document' class brenda C++ 11 May 23rd, 2005 8:10 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:34 AM.

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