We would like to know how to concurrent reads on an InputStream.
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; //from ww w . j a va 2 s . c om public class Main { public static void main(String[] args) throws IOException { ExecutorService service = Executors.newFixedThreadPool(4); BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in)); String line; while ((line = buffer.readLine()) != null) { service.execute(new Worker(line)); } } } class Worker implements Runnable { private final String line; public Worker(String line) { this.line = line; } @Override public void run() { System.out.println("Processing line: " + line); } }