dcsimg
Deadlock when accessing synchronized methods
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Christer_Nordvik
Posted On:   Friday, September 20, 2002 07:27 AM

I have a socket server running which clients can log into and recieve notifications, but sometimes the clients can't log in(the thread stops when adding an object to a synchronized collection of clients, using a Vector). My Java code(a small part): public class OutStreams { private static Vector streams = new Vector(); public synchronized void add(ClientConnection c) { ... } public synchronized void remove(ClientConnection c) { ... } public synchronized ClientConnection get(String id) { ... } The threads are the following(not included all that are in runnable state):    More>>

I have a socket server running which clients can log into and recieve notifications, but sometimes the clients can't log in(the thread stops when adding an object to a synchronized collection of clients, using a Vector).


My Java code(a small part):

			
public class OutStreams {
private static Vector streams = new Vector();
public synchronized void add(ClientConnection c)
{
...
}
public synchronized void remove(ClientConnection c)
{
...
}
public synchronized ClientConnection get(String id)
{
...
}




The threads are the following(not included all that are in runnable state):


			
Full thread dump OJVM Client VM (9.0.3.713 cdov):

"Reference Handler" prio: 10 state: waiting
void java.lang.Object.wait(long)
native code
void java.lang.Object.wait()
Object.java:426
void java.lang.ref.Reference$ReferenceHandler.run()
Reference.java:113

"Finalizer" prio: 8 state: waiting
void java.lang.Object.wait(long)
native code
java.lang.ref.Reference java.lang.ref.ReferenceQueue.remove(long)
ReferenceQueue.java:111
java.lang.ref.Reference java.lang.ref.ReferenceQueue.remove()
ReferenceQueue.java:127
void java.lang.ref.Finalizer$FinalizerThread.run()
Finalizer.java:159


"Thread-311" prio: 6 state: waiting
java.lang.Class java.lang.Object.getClass()
native code
boolean org.apache.log4j.CategoryKey.equals(java.lang.Object)
CategoryKey.java:36

"Thread-3" prio: 6 state: runnable
void java.net.SocketOutputStream.socketWrite0(java.io.FileDescriptor, by
te[], int, int)
native code
void java.net.SocketOutputStream.socketWrite(byte[], int, int)
SocketOutputStream.java:92
void java.net.SocketOutputStream.write(int)
SocketOutputStream.java:105
void java.io.DataOutputStream.writeBytes(java.lang.String)
DataOutputStream.java:256
boolean prevision.socketserver.OutStreams.sendMessage(java.lang.String,
prevision.socketserver.ClientConnection)
OutStreams.java:274
void prevision.socketserver.OutStreams.sendAlarmListToAllClients(previsi
on.socketserver.SocketServer)
OutStreams.java:169
void prevision.socketserver.JMSThread.checkForNewAlarms()
JMSThread.java:95
void prevision.socketserver.JMSThread.run()
JMSThread.java:46


"Thread-319" prio: 6 state: waiting
java.lang.Class java.lang.Object.getClass()
native code
boolean org.apache.log4j.CategoryKey.equals(java.lang.Object)
CategoryKey.java:36



If anyone could help me out then I would really appreciate it!. I just can't see where I have gone wrong or which threads are causing the problem.

Regards,

Christer Nordvik
System Developer    <<Less

Re: Deadlock when accessing synchronized methods

Posted By:   Mike_Friedrich  
Posted On:   Saturday, September 21, 2002 01:16 AM

Can you post your CategoryKey.java, i think its inside of this class.

Re: Deadlock when accessing synchronized methods

Posted By:   Christopher_Schultz  
Posted On:   Friday, September 20, 2002 11:25 AM

Its weird, but it looks like log4j has stopped waiting for a lock obtaining the Category object. Are you doing anything weird with log4j?



-chris
About | Sitemap | Contact