/* * Vorlesung "Vernetzte Systeme" WS 1999/2000, Prof. Dr. F. Mattern * ---------------------------------------------------------------- * SyncPrintWriter.java: * allows multiple threads to share the same outstream by _synchronizing_ * the println method. */ import java.io.*; // "Synchronization and Threads", see // http://java.sun.com/docs/books/tutorial/essential/threads/monitors.html public class SyncPrintWriter extends PrintWriter { public SyncPrintWriter(OutputStream out, boolean autoFlush) { super (out, autoFlush); } /* note: we should really be protecting all applicable methods, but our * programs only use the println method, so this is enough for our * purpose! */ public synchronized void println(String s) { super.println (s); } }