All pastes #30185 Raw Edit

Someone

public java v1 · immutable
#30185 ·published 2005-11-22 01:57 UTC
rendered paste body
//=== Test.javaimport java.io.*;public class Test{	protected PipedInputStream		utilIn			= new PipedInputStream();	protected PipedOutputStream		utilOut			= new PipedOutputStream();	protected PrintStream			utilOutPrinter	= new PrintStream( utilOut );	protected BufferedReader		utilInReader	= new BufferedReader( new InputStreamReader( utilIn ) );		public static void main( String[] args ) 	{		new Test();	}		public Test()	{		try		{			utilIn.connect( utilOut );			new FeedbackListener( utilInReader ).start();			new DoStuff( utilOutPrinter ).start();			new Blah().start();		}		catch ( Exception e )		{			e.printStackTrace();		}	}				class FeedbackListener extends Thread	{		BufferedReader in;		PrintStream out;				public FeedbackListener( BufferedReader in )		{			this.in = in;		}				public void run()		{			System.out.println( "Feedback running" );			try			{				String line;				while ( ( line = in.readLine() ) != null )				{					System.out.println( "PIPED: " + line );				}			}			catch ( IOException ie )			{				ie.printStackTrace();			}		}	}		class Blah extends Thread	{		public void run()		{			while ( true )			{				// If this is uncommented, the pipes stay open.				//utilOutPrinter.println( "." );				try				{					sleep( 10000 );				}				catch ( Exception e )				{					e.printStackTrace();				}			}		}	}}//=== DoStuff.javaimport java.io.*;public class DoStuff extends Thread{	private PrintStream out;		public DoStuff( PrintStream out )	{		this.out = out;	}		public void run()	{		out.println( "Do: Blah" );		// When this is done out is closed.	}}