/* * Vorlesung "Vernetzte Systeme" WS 1999/2000, Prof. Dr. F. Mattern * ---------------------------------------------------------------- * PipeLineSendThread.java * delay sending data packet for fixed amount of time * * Required Classes: * - SyncPrintWriter: * Allows multiple threads to share a single output stream. */ import java.net.*; import java.io.*; public class PipeLineSendThread extends Thread { private String inputLine = null; private SyncPrintWriter out = null; private int wait = 0; public PipeLineSendThread(String inputLine, SyncPrintWriter out, int wait) { super("PipeLineSendThread"); // call constructor "Thread(string)" // and name this thread this.inputLine = inputLine; this.out = out; this.wait = wait; } public void run() { try { Thread.sleep(wait); } catch (InterruptedException e){ // the VM doesn't want us to sleep anymore, so get back to work } // relay input line out.println(inputLine); } }