+5  A: 

instead of

stderrprocessor.run(); //<-- the block occurs here!
stdoutprocessor.run();

You need to start threads:

Thread errThread = new Thread(stderrprocessor);
errThread.setDaemon( true );
errThread.start();

Thread outThread = new Thread(stdoutprocessor);
outThread.setDaemon( true );
outThread.start();

run() is just a method specified in Runnable. Thread.start() calls run() on the Runnable in a new Thread.

Clint
+1  A: 
  1. If you just call #run() on a runnable, it will not be executed in parallel. To run it in parallel, you have to spawn a java.lang.Thread, that executes the #run() of your Runnable.
  2. Whether a stream blocks depends on both sides of the stream. If either the sender does not send any data or the receiver does not receive data, you have a block situation. If the processor has to do something, while the stream is blocked, you need to spawn a(nother) thread within the processor to wait for new data and to interrupt the alternate process, when new data is streamed.
oeogijjowefi
A: 

First, you need to read up on Thread and Runnable. You do not call Runnable.run() directly, you set up Threads to do that, and start the threads.

But more important, the presence of three independent threads implies the need for some careful design. Why 3 thread? The two you just started, and the main one.

I assume that the generall idea of your app is to wait for some output to arrive, interpret it and as a result send a command to the application you are controlling?

So your main thread needs to wait around for one of the reader threads to say "Aha! that's interesting, better ask the user what he wants to do."

In other words you need some communication mechanism between your readers and your writer. This might be implemented using Java's event mechanism. Yet more reading I'm afraid.

djna
A: 

Isn't this why the nio was created?

I don't know much about the Channels in nio, but this answer may be helpful. It shows how to read a file using nio. May be useful.

OscarRyz