java - Multi-Thread BufferedReader for reading .txt -
i'm wanting read line of .txt task, , move on next line.
to make program quicker, want multi-thread each thread tries line.
the problem is, don't want thread 1 trying same line thread 2.
any ideas?
i suggest have one thread doing reading, put lines producer/consumer queue (e.g. linkedblockingqueue) - can have multiple threads servicing queue consumers.
you don't want multiple threads performing io here - if had multiple independent bufferedreaders, if you're reading traditional disks don't want end seeking in multiple places. producer/consumer queue separates reading handling - , makes easier test each part in isolation well.
Comments
Post a Comment