Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!feeder.erje.net!usenet.ukfsn.org!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: A independant pile for communication Date: Wed, 30 May 2012 20:53:01 +0000 (UTC) Organization: UK Free Software Network Lines: 18 Message-ID: References: <4fc5bb99$0$1706$426a74cc@news.free.fr> NNTP-Posting-Host: 84.45.235.129 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: localhost.localdomain 1338411181 26875 84.45.235.129 (30 May 2012 20:53:01 GMT) X-Complaints-To: usenet@localhost.localdomain NNTP-Posting-Date: Wed, 30 May 2012 20:53:01 +0000 (UTC) User-Agent: Pan/0.135 (Tomorrow I'll Wake Up and Scald Myself with Tea; GIT 30dc37b master) Xref: csiph.com comp.lang.java.programmer:14945 On Wed, 30 May 2012 08:18:01 +0200, Olve wrote: > I could create a pile of message, create a Thread and have this pile > being read and displayed in run() with a wait() if the pile is empty and > a notifyAll() when the pile is fed. Using some sort of Queue to hold the messages would be most usual approach. Almost anything can be used to add messages: using transient threads that just add a message when its presented to your program, e.g. via e-mail or via a Socket, and then die is a possibility. The benefit of using a Queue is that the thread(s) processing the messages will block automatically when the Queue is empty. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |