[concurrency-interest] Basic question on making a thread waiting for 2 mailboxes...

Fred Janon fjanon at gmail.com
Mon Apr 23 09:53:33 EDT 2007


Hi,

I used to write real time apps using RSX11M+ (and VMS) that had mailboxes
and events. There was a "wait for OR(events)". The task would wait for any
event specified in the OR. Then I would associate an event with a mailbox,
do that for another mailbox and when a message would arrive in one of the 2
mailboxes, the task would awake. I am trying to do that in Java with
threads.

I have been reading "Java Threads",  "JCIP", "Java in a Nutshell" and I
could think about a couple of classes I could use but I would appreciate
some design advice... Or if there is an existing library that does that
already does that, I would appreciate a reference, I did some research and
did not find anything interesting.

Basically I need 1 public mailbox and 1 private mailbox for a thread. The
thread would be blocked until a message arrives in one of the mailboxes. The
mailboxes must have multiple slots. I was thinking about using
LinkedBlockingQueues as mailboxes since I don't want to block the sender (or
avoid it) but I am a bit stuck on making the thread wait for a message in
either queues.

The next step would be to have a ThreadPool for the tasks, sharing a common
public mailbox to process the messages and each have a private mailbox for
system management messages. I guess switching to a single thread to a
ThreadPool would be relatively easy?

Thanks in advance.

Fred
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20070423/2b2b9aea/attachment.html 


More information about the Concurrency-interest mailing list