import java.io.FileReader; import java.io.File; import java.io.BufferedReader; import java.io.IOException; import java.io.FileNotFoundException; import java.util.concurrent.LinkedBlockingQueue; import java.util.Queue; public class Foo { public static void main(String args[]) throws FileNotFoundException { LinkedBlockingQueue<String> queue = new LinkedBlockingQueue<String>(); int count = 0; Popper<String> thread = new Popper<String>(queue); thread.start(); BufferedReader reader = new BufferedReader(new FileReader(new File(args[0]))); try { String line; while ((line = reader.readLine()) != null ) { queue.add(line); count += 1; } System.out.println(count); } catch (IOException e) { // nothing, we break } thread.interrupt(); } }