The Problem: This problem is based on the chat room example from chapter 10 of Jason Hunter's OReilly Java Servlet Programming. The example consists of a servlet, a message source class for holding and sending messages and a message sink class that is an observer of the message source that returns the message.
This is where my misunderstanding comes in: the servlet contains the line "MessageSource source = new MessageSource();" which in my understanding gives the servlet thread its own instance of the MessageSource object called source. The MessageSource class extends Observable, and if a message is sent to MessageSource, it calls notifyObservers. When a new message comes into the servlet to the doGet method (used for waiting for a new message), the servlet asks for the next message from the message sink with the line "String returnMsg = new MessageSink().getNextMessage(source, room);" . So the servlet calls its own instance of MessageSink. MessageSink is an Observer of the source with the line "source.addObserver(this);" where the source is the source instance passed from the servlet. Now, if my understanding is correct each independent thread of the servlet has its own instance of the source and its own instance of the MessageSink that is an observer of its own source object. I want to know how when one client posts a message, how do the other threads of the servlet (the other clients) get the message??? The only other thing that I think is relevant is the methods of the MessageSink class are synchronized, but I still do not see how this would help given that there are different threads. Thanks for the help - Scott Carter ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html