/* Class Msg_port implements a simple communication port of the server that processes transactions */ public class Msg_port { // type of monitor private Message port_memory; // buffer for the message private boolean empty; // flag public Msg_port () {empty = true;} public boolean empty_port() {return empty;} synchronized public void write (Message request) { while (!empty) try { wait(); // calling thread waits } catch (InterruptedException e) {} port_memory = request; empty = false; notify(); // awaking of a waiting thread } synchronized public Message read () { while (empty) try { wait(); } catch (InterruptedException e) {} empty = true; notify(); return port_memory; } }