// PServer1 - A simplified Print Server. Not a complete application! // Written 2/2001 by Wayne Pollock, Tampa Florida USA. Adopted from // "The Java Programming Language" 3rd Ed. by Ken Arnold, James // Gosling, and David Holmes. (C) 2000 by Sun Microsystems, Inc. // Published by Addison-Wesley. Pages 233-ff. import java.util.LinkedList; class PServer1 implements Runnable { private LinkedList requestList = new LinkedList(); public PServer1 () { new Thread( this ).start(); // Create and start thread. } public void addPrintJob( PrintJob job ) { requestList.add( job ); // ... Let the PServer thread know a print job has been queued. } public void run () { for ( ;; ) { while ( ! requestList.isEmpty() ) printIt( (PrintJob) requestList.removeFirst() ); // Wait for more print jobs. } } private void printIt ( PrintJob job ) { // ... Do real job of printing here } } class PrintJob { // ... }
Send comments and mail to the WebMaster. |