Java tutorial
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; 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); } }