Exercises


  • 10.1 Ignoring the feature that allows objects of the Channel class to be used in a select, program a monitor in Java that implements the send and receive operations on channels (i.e. consider that Channel is not derived from Selectable).

  • Optional: Test your implementation by using it, instead of the provided Channel class, in the synchronous message-passing demonstration applet.

  • 10.2 Modify your implementation of the previous exercise such that the receive operation can time out. The receive becomes:

     synchronized Object receive(int timeout);

  • If the timeout period expires before a message is sent to the channel, the receive operation returns the value null.

  • 10.3 Design a message-passing protocol which allows a producer process communicating with a consumer process by asynchronous messaging to send only a bounded number of messages, N, before it is blocked waiting for the consumer to receive a message. Construct a model which can be used to verify that your protocol prevents queue overflow if ports are correctly dimensioned.

  • Optional: Design and implement an applet which demonstrates the operation of your protocol.

  • 10.4 Translate the bounded buffer outline of section 10.3.3 into Java using the Entry and Select classes.

  • Optional: Modify the bounded buffer applet of Chapter 5 to use this implementation rather than the monitor.




Concurrency(c) State Models & Java Programs
Concurrency: State Models and Java Programs
ISBN: 0470093552
EAN: 2147483647
Year: 2004
Pages: 162

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net