// The PipeTest example // but slightly rewritten to factor out // some common code: // // introduced an abstract class OutputtingThread which // is sub-classed by both FibMaker and PrimesMaker, // uses init-method instead of a constructor import java.io.*; public class PipeTest { static int max = 100000; static public void main(String[] args) { if (args.length > 0) { try { max = Integer.parseInt(args[0]); } catch (Exception e) {} } PipeTest world = new PipeTest(System.out); } private PipeTest(PrintStream out) { DataInputStream fibs = (new FibMaker()).init(); DataInputStream primes = (new PrimesMaker()).init(); try { int x = fibs.readInt(); int y = primes.readInt(); while (x < max) { if (x == y) { out.println(x + " is both fib and prime"); x = fibs.readInt(); y = primes.readInt(); } else if (x