// Melvin K Lew <melvin@columbia.edu>
// $Source: /amd/cheers-fast/root/np/melvin/AIS/aisproj/RCS/WBCPrintThread.java,v $
// $Date: 1998/04/27 01:58:24 $
// $Author: melvin $
// $Revision: 1.6 $
//
// CS-E6998-03 Advanced Internet Services: Term Project
//
// The JINCS Project: Collaborative Whiteboard Client/Server Application
//
// Group:
//	Johan Andersen <johan@columbia.edu>
//	Richard Denmark <thor@columbia.edu>
//	Melvin Lew <melvin@columbia.edu
//
// A multi-threaded networked Whiteboard Server
//

import java.io.*;
import java.lang.*;

/**
 * Extends Thread objects, these thread objects are spawned to handle
 * the transmission of data from the server to the client.  One instance
 * of WBCPrintThread is spawned for each command sent to each client.
 *
 * @author	Melvin K Lew
 * @version	$Revision: 1.6 $, $Date: 1998/04/27 01:58:24 $
 *
 * @see		WBCListenThread
 * @see		WBCParser
 */
public class WBCPrintThread extends Thread
{
  private ClientInfo clientinfo = null;
  private PrintWriter pwout = null;
  private String str = null;

  /**
   * Class constructor.
   *
   * @param	clientinfo	a ClientInfo object for the client
   * @param	str		a string to be sent to the client
   *
   * @see	ClientInfo	
   */
  public WBCPrintThread(ClientInfo clientinfo, String str)
  {
    this.clientinfo = clientinfo;
    this.pwout = clientinfo.getPwout();
    this.str = str;
  }

  /**
   * The execution part of this thread simply utilizes the PrintWriter.
   */
  public void run()
  {
    // synchronize on the PrintWriter to not interfere with other threads
    synchronized ( pwout ) {
      pwout.print(str);
      pwout.flush();

      return;
    }
  }
}
