Class MessageSync<M extends Message>

Type Parameters:
M - the type of the messages
All Implemented Interfaces:
MessageReceiver<M>

public class MessageSync<M extends Message> extends MessagePasser<M>
Can accept messages from many different parallel threads.

The public receive(Message) method is declared "synchronized", so that a monitor is opened on each call. A second call from a different thread will wait until the first call has completed.

  • Constructor Details

    • MessageSync

      public MessageSync()
      Minimal constructor. For that a message can be received, the drain must be set to a non-null value.
    • MessageSync

      public MessageSync(@Opt @Opt MessageReceiver<? super M> r)
      Constuctor setting the drain. For that a message can be received, the drain must now or later be set to a non-null value.
      Parameters:
      r - the drain of this filter
  • Method Details

    • receive

      public void receive(M m)
      Central point of service. This method is declared synchronized, so that a monitor is opened on each call. A second call from a different thread will wait until the first call has completed.
      Specified by:
      receive in interface MessageReceiver<M extends Message>
      Overrides:
      receive in class MessagePasser<M extends Message>
      Parameters:
      m - the message to receive.